WHen getting query results I cant read hebrew

Discussion in 'Android Questions' started by danoptic, Mar 19, 2013.

  1. danoptic

    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
     
  2. danoptic

    danoptic Member Licensed User

    DB collation utf8_gunicode_ci

    DB collation utf8_unicode_ci and not utf8_general_ci
     
  3. Erel

    Erel Administrator Staff Member Licensed User

  4. danoptic

    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?
     
  5. Erel

    Erel Administrator Staff Member Licensed User

    You can use this method:
    Code:
    Log(UnescapeUnicode("this is  a test \u05d3\u05df.")) 'prints: this is  a test דן.

    Sub UnescapeUnicode(s As StringAs 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: May 28, 2018
    ilan and Mashiane like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice