Android Question Emoji storage and UTF8

Discussion in 'Android Questions' started by AndOrNot, Jul 5, 2016.

  1. AndOrNot

    AndOrNot Well-Known Member Licensed User

    Hi all, i have a little server hosted in altervista .org. Mysql db of altervista doesn't support utf32 , or utfmb4, so when i try to insert an emoji on editbox my app can see it, but when i store the message in db online it will store "????". So i think the i can replace emoji from my edit box with a spefic value, for example hex value of emoji or unicode.

    I can write emoji using its codeint (e.g 1f600) with the following code:
    Code:
    Dim bc As ByteConverter
    Dim b() As Byte = bc.IntsToBytes(Array As Int(0x1F600))
    Msgbox(BytesToString(b, 04"UTF32"),"")
    But i am not able to get the code from the emoji wrote in edittext, before send it in db. Can anyone help me? I tried the following code, but it doesn't works

    Code:
    Dim b() As Byte = bc.StringToBytes(text,"UTF32")
      
    Dim c() As Int = bc.IntsFromBytes(b)
      
    Msgbox(c(0),0x1F600)
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    Why do you convert it to an array of ints? Why not store it as a blob (array of bytes)?
     
  3. AndOrNot

    AndOrNot Well-Known Member Licensed User

    I have an entire text, and maybe in this text there are emoticon. Should I convert all text as blob and store in db blob like text?
     
  4. AndOrNot

    AndOrNot Well-Known Member Licensed User

    I solved it using the following code

    Put:
    Code:
    Dim text2 As StringUtils
    Dim b() As Byte = text2.DecodeBase64(m.Get("Colum"))
    lbl2.Text = 
    BytesToString(b,0,b.Length,"UTF-8")
    Read:
    Code:
    Dim su As StringUtils
    Dim query As String = "INSERT INTO Commenti (Colum) VALUES ('"&su.EncodeBase64(txtComm.Text.GetBytes("UTF8")&"')
     
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