Mariadb and utf8

Hello,

There are strange characters on fields retrieved from a table of database, however retrieving records using heidi or navicat are shown correctly.
Database is mariadb and collate is utf8_general_ci

What am I doing wrong ?

Thank you

The font used to display the non ASCII texts ?

Datata is retrieved using recordset

rs.IdxField(j).StringValue

This seems correct if the data are strings…

It sounds like an encoding issue, when retrieving the data, do you define the encoding as utf8 when retrieving the data. Take a look in the xojo manual at Define Encodings and try below to see if you get a better result.

result=DefineEncoding(rs.IdxField(j).StringValue, Encodings.utf8)

The table schema is

CREATE TABLE test.test (
ID int(11) NOT NULL AUTO_INCREMENT,
NAME text CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
PRIMARY KEY (ID) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 13640 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

Regardless of the table definition, please give @Paul Budd’s suggestion a try. You may well be happy with the results.

[quote=415792:@Jaume Jaume]Datata is retrieved using recordset

rs.IdxField(j).StringValue[/quote]

AFAIK those Strings have no defined Encoding. You have to define the Encoding like @Paul Budd wrote.

Paul, you were right. it is working fine.
Thank you.

Xojo works using utf8, database encoding is utf8. Do you know the reason why we have to encode ? besides sqlite doesn’t require to encode.

thank you

Norman once told me this:

You can, and you need to, define the encoding inside a SQLite database WHEN you create it. Despite this, I set the encoding on any relevant text coming from a SQLite database, just to make sure. Same with MySQL.

I’m going to be mad.

I created a Mariadb database using utf8 collation. It works fine using encodings every time I read a record from database.

Later, I installed prestashop (mariadb database, utf8 collation) and updated some records from the first mariadb database using a string variable

sql =“UPDATE pso_customer SET name=” + chr(34) + rs.field(“name”).StringValue + chr(34) + " WHERE " …

After that, strange characters are shown on prestashop database.

Any ideas ?

Thank you

not related to your original question… but I highly suggest the use of PREPARED STATEMENTS especially in an UPDATE like that on