Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kotlin URL().readText(), how to convert string from return

I'm stacked by converting string, here is my code:

fun getCurrentTitle() {
    doAsync {
        val str = URL("http://10.0.0.8:4800/${Utils.TITL}").readText(Charset.forName("UTF-8"))
        uiThread {
            current_song_title.text = str
            System.out.println(str)
        }
    }
}

here is string that i get returned (in TextView is same)

I/System.out: Ti�sto - On My Way

and in Web-Browser returns correct string

Tiėsto - On My Way

I dont have idea what i do wrong...

Thanks in advance!

Edit If someone have same issue, here is solution. Thans to Vivick

val url = URL("http://10.0.0.8:4800/${Utils.TITL}").readText(Charset.forName("ISO-8859-1"))

like image 1000
Milos Lulic Avatar asked Aug 31 '25 05:08

Milos Lulic


1 Answers

As concluded in the comments, just utilize the ISO-8859-1 charset in order to see the characters you want.

(This is just a reiteration in order to get this post marked as solved)

like image 85
Mr.Midnight Avatar answered Sep 02 '25 20:09

Mr.Midnight