WHen getting query results I cant read hebrew

danoptic

Member
Licensed User
I get the result from the log:
job: ? [{"id":"1","first_name":"???","last_name":"???","phone_home":"","phone_mobile":"","address_id":"1","delivery_address":"2","active":"1","create_date":"2013-03-17 00:00:00","last_update":"2013-03-14 10:56:26"}]

HEBREW looks like ????? and I get the ? at the beginning

I use mysql on a linux server
DB collation utf8_general_ci
when I use phpMyAdmin everything is OK.

Thanks
 

danoptic

Member
Licensed User
How can I read the result string

After chaging php code I receive hebrew like that
"\u05d3\u05df"

How do I make it readable?
 
Upvote 0

Erel

Administrator
Staff member
Licensed User
You can use this method:
B4X:
Log(UnescapeUnicode("this is  a test \u05d3\u05df.")) 'prints: this is  a test דן.

Sub UnescapeUnicode(s As String) As String
   Dim sb As StringBuilder
   sb.Initialize
   Dim i As Int
   Do While i < s.Length
      Dim c As Char = s.CharAt(i)
      If c = "\" AND i < s.Length - 1 AND s.CharAt(i + 1) = "u" Then
         Dim unicode As StringBuilder
         unicode.Initialize
         i = i + 2
         Do While i < s.Length
            Dim cc As String = s.CharAt(i)
            Dim n As Int = Asc(cc.ToLowerCase)
            If (n >= Asc("0") AND n <= Asc("9")) OR (n >= Asc("a") AND n <= Asc("f")) Then
               unicode.Append(s.CharAt(i))
            Else
               i = i - 1
               Exit
            End If
            i = i + 1
         Loop
         sb.Append(Chr(Bit.ParseInt(unicode.ToString, 16)))
      Else
         sb.Append(c)
      End If
      i = i + 1
   Loop
   Return sb.ToString
End Sub
 
Last edited:
Upvote 0
Top