Android Question SQLite character encoding vs GetBytes

Robert Bussey

Member
Licensed User
Longtime User
After many hours of due diligence (ie; head banging) I must, once again, call upon the greater wisdom.
I have a SQLite db encoded in ANSI. It is years old, created on PC, and can not be reproduced. There are 2 fields that must be read as ASCII/ANSI characters.

I can't find any way to force SQLite in b4a to set ANSI char. set which would be a preferred solution so have done this bit of code:
B4X:
' in is the result of sql.getstring
' out is not used in this example
Sub Decrypt(In As String, Out As String)
   Dim n1() As Byte
   Dim x As Int
   n1=In.GetBytes("UTF8")
   For x=0 To n1.Length-1 'want to  see the result of getbytes
     Msgbox (n1(x),Chr(n1(x)))
   Next
End Sub

Some kind of translation happens but I have no idea what.
Any help will be most appreciated!
Bob
 

Palle

Member
Licensed User
Thank you Erel! It works fine.

B4X:
Sub ConvertUTF8(b() As Byte) As String
Return BytesToString(b, 0, b.Length, "Windows-1250")
End Sub

ConvertUTF8(Cursor1.GetBlob("Name1"))
 
Upvote 0
Top