TextView не форматирует текст

У меня есть текст:

"Certainly! Here's an example of some simple Python code that prints \Hello, World!\ to the console:\n\npython\\nprint(\\Hello, World!\\)\\n\n\nThis code uses the print() function, which is a basic Python function that outputs text to the console.\n\nIf you would like to see another example or a specific type of \easy code,\ please let me know what you're interested in!"

А мне надо чтобы он TextView смог видеть \n и красиво отображал.

if (responseCode == HttpURLConnection.HTTP_OK) {val inputStream = httpURLConnection?.inputStream
val response1 = inputStream?.bufferedReader().use { it?.readText() }
val response2 = "$response1"
val response3 = response2.replace("\"", "")
val response = HtmlCompat.fromHtml(response3,HtmlCompat.FROM_HTML_MODE_COMPACT)

Я тут в общем убираю кавычки, из текста и потом хочу сделать форматирование HTML, но ничего не выходит.

Код выглядит не очень сразу говорю, пока для теста.


Ответы (1 шт):

Автор решения: Navsikaya

Проблема решена

 val response3 = System.getProperty("line.separator")?.let { response2.replace("\\n", it) }
                    val response4 = response3?.replace("\\", "")
                    val response = response4?.substring(1, response4.length - 1)
→ Ссылка