Android Question [RESOLVED] Sending Chat messages with Emoji's using websockets

Jmu5667

Well-Known Member
Licensed User
Hello

We have build a chat app (B4A) which connects to a Chat server (B4J), backend Database is SQL server. Is there a special method required when sending the data to the server. Currently I get ?? on the receiver client instead of the emoji.

thanks

John.
 

Jmu5667

Well-Known Member
Licensed User
The solution:

Encode the message before you send it, I store the encode message in SQL DB, when the message arrives to the other device it is decoded.

Thanks for the help @OliverA :)

Hope this is of use to someone else.

Regards

John.

B4X:
Sub encode_message(pData As String) As String
   
   Dim su As StringUtils
   Dim bytes() As Byte
   
   Try
       bytes = pData.GetBytes("UTF32")
       Return su.EncodeBase64(bytes)
   Catch
       Return pData
   End Try
   
End Sub

Sub decode_message(pData As String) As String
   
   Dim su As StringUtils
   Dim bc As ByteConverter
   Dim bytes() As Byte
   
   Try   
       bytes = su.DecodeBase64(pData)
       Return bc.StringFromBytes(bytes,"UTF32")
   Catch
       Return pData
   End Try
   
End Sub
 
Upvote 0
Top