B4J Question [Solved] Show and edit a textfield with emoji and text

asales

Expert
Licensed User
Longtime User
I have a sqlite table with fields that have emojis and text:

sqlite_emoji1.jpg


When I try to load this content in a TextField:
B4X:
tfTitle.Text = rs.GetString("title")
tfNotification.Text = rs.GetString("message")
The emojis is not show correctly:
notify_emoji1.jpg

How can I show (load from sqlite), edit and save this fields with emojis and text?

Thanks in advance for any tip.
 

asales

Expert
Licensed User
Longtime User
Does it show properly if you set the string directly in the code?
Please post the text as text.
Directly works:
B4X:
tfTitle.Text = "New version in Play Store ?❤️?"
tfNotification.Text = "This is a notification test ? Check this ??♥️"
notify_emoji2.jpg


Read from SQLite, don't':
B4X:
Dim rs As ResultSet = B4XPages.MainPage.sql1.ExecQuery("SELECT id, title, message, sended FROM notifications WHERE id = " & B4XPages.MainPage.id_msg)
notify_emoji3.jpg
 
Upvote 0

TILogistic

Expert
Licensed User
Longtime User
remember that emojis are unicode.

and from what I see it does not convert them.

can you upload an example of dbase sqlite.
 
Upvote 0

asales

Expert
Licensed User
Longtime User
remember that emojis are unicode.

and from what I see it does not convert them.

can you upload an example of dbase sqlite.
Thanks for the answer.

Here the project with the sqlite database.

I use the SQLiteStudio tool to create the original database and the fields is filled with a Delphi program.
In both I can see the text and emojis in the fields.

Now I try to port to B4J, but I get stuck with this problem to show and edit the unicode content of the fields.
 

Attachments

  • b4jsendertool.zip
    15.7 KB · Views: 149
Last edited:
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. This is considered broken code:
B4X:
Dim rs As ResultSet = sql1.ExecQuery("SELECT id, titulo, mensagem FROM mensagens WHERE id = " & id_msg)
2. You are not closing the ResultSet.
3. Using File.DirApp is a mistake if you plan to release your app as a standalone app.
4. Using B4XPage_Appear is almost always a mistake. B4XPages are much simpler than activities and you don't need to wait for the page to appear to do something.


1644818902714.png


Looks like the jdbc driver uses the incorrect encoding. Get the bytes directly and convert them to string:
B4X:
Dim b() As Byte = rs.GetBlob("titulo")
tfNotification.Text = BytesToString(b, 0, b.Length, "utf8")
 
Upvote 1
Top