Android Question Converting latin1_swedish_ci charecters

shashkiranr

Active Member
Licensed User
Longtime User
Hi All,

I have a string which is retreived from db as

B4X:
Kalyāni

But I want it to be displayed as

B4X:
Kalyāni

Any idea how I can convert it?

Best,
SK
 

DonManfred

Expert
Licensed User
Longtime User
Have you tried to use
B4X:
' returns a 2-bytes-UTF8 String from a 16-Bit Android String
Sub android2utf(android As String) As String
    Dim c() As Byte = android.getbytes("UTF-8")
    Dim utf As String =""
    Dim m As Int = c.Length-1
    For i=0 To m
        utf = utf & Chr(c(i))
    Next
    Return utf
End Sub

' returns a 16-Bit Android String from 2-bytes-UTF8 String
Sub utf2android(utf As String) As String
    Dim m As Int = utf.Length-1
    Dim i As Int
    Dim android(m+1) As Byte
    For i=0 To m
        android(i) = Asc(utf.CharAt(i))
    Next
    Return BytesToString(android, 0, android.Length, "UTF-8")
End Sub
 
Upvote 0

shashkiranr

Active Member
Licensed User
Longtime User
Hi Erel,

I found the html decoder n it worked. thank u for sharing it.

Hi Kmatle,

The data is coming from a mysql db.

Best,
SK
 
Upvote 0
Top