saving emoji in string type

Hi,

I have a chat in my APP and works fine bu when I use emoji char i have a problem.

‘Server.Processing’ [java.lang.RuntimeException: java.lang.RuntimeException: com.mysql.jdbc.MysqlDataTruncation: Data truncation: Incorrect string value: ‘\xF0\x9F\x98\xAC\xF0\x9F…’

My code is

    if (messageTextView.text == "") {
        print("no text")
    }
    else {
        messages.publish = userName
        messages.subscribe = otherName
        messages.message = self.messageTextView.text
        
        dataStore.save(messages, fault: &error) as? Messages
        if (error == nil) {
            self.messageTextView.text = ""
            self.refreshResults()
        }
        else {
            print("Server reported an error: \(error)")
















        }

Hi Rubens,

I scheduled an internal ticket to investigate this problem.

Regards,
Mark

Hi, Rubens,

The issue is linked to support topic. “Our database charset is utf8_general_ci and emojis cannot be properly saved for this encoding.”

As a workaround we can suggest you to:

  1. Create custom event handlers on before create item to encode it from utf-16 to utf-8 like this:
String stringField  = new String( stringField.toBytes("UTF-16") , "UTF-8")
  1. So when you retrieve item you create custom event handlers on after find to encode it back from utf-8 to utf-16.

Let us know if this approach made a trick.

Cheers,
Artur.

Thanks Artur,

I created a custom event handlers and works fine except when i get a remote notification in background (IOS) because i can´t treat it

Are the emoji characters included into the notification?

Yes

Can you do the UTF-8 to UTF-16 conversion on the device? Here’s a thread discussion this topic: http://stackoverflow.com/questions/13058325/how-to-convert-nsdata-utf8-encoded-data-to-utf16

Thanks Mark,

But … as I said earlier the encode/decode works fine for me because I process in my code.
(UTF-8 to UTF-16) and (UTF-16 to UTF-8) it´s ok.
The only problem is when the message comes to me by notification (in background in IOS) because I can´t handle the message)

Hi!

FYI: we added new data type (EXTENDED_STRING) to support emoji in data service: example1 and example2

Regards,
Kate.

I just ran into this problem and almost had a heart attack until I saw this fix. You are awesome!

This is great news … especially those who work with chat.

Very very good

Spoke too soon. Kate, have you tested the extended strings with the mobile SDK’s? In my iOS app all strings that have emojis are coming back as nil in the app. I can see the emojis in the dashboard. Maybe the respective SDK’s aren’t updated yet?

Hi Allen!

We are working on this issue (task id is BKNDLSS-12698).
IOS dev will notify you about changes.

Hello Rubens
I am also facing the same problem, need to send notification with emojis
Please share your experience and how to use this EXTENDED STRING type for sending the notification

This thread is about emojis in persistence, to use it just change type of your data to EXTENDED STRING https://monosnap.com/file/ESlwQdp7iG68C4LlPrhtMP1zFTwhox . But as I understand you have problem with sending push notifications ? Please provide more information about your issue

Hello Sergey thanks for reply

My problem is when I am integrating chat functionality in my app using message sub/pub and push notifications. when I am sending emojis in messages it is converting to ‘??’. But I managed to encode and decode using unicode in pub/sub messaging but in push notification i cannot do that as we cannot alter the banner text of notification, even when I am sending the notification from backendless console then also its not working fine. please find the attached screenshots

I have created internal ticket BKNDLSS-12797

Thanks for the favour.

Please update the libs from github (CoomLibiOs & backendless), and try again

Hi,do you fix this issue

I am still getting null