accentuation and MariaDB

Linux specific forum
User avatar
holzhacker
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Mar 08, 2010 9:14 pm
Location: "Mens sana in corpore sano"
Contact:

accentuation and MariaDB

Post by holzhacker »

Problems with accentuation and MariaDB.

I noticed that when the data is entered and read directly by Purebasic using the new MariaDB library the data is written and retrieved with accents correctly, however, when I try to read some previously fed database, I can not recover with the correct accent.

Would anyone know of something to do to also be able to use PureBasic on previously powered databases?

thanks for listening!
Greetings and thanks!

Romerio Medeiros
romerio@gmail.com
Fred
Administrator
Administrator
Posts: 16619
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: PB 5.70 B4 - accentuation and MariaDB

Post by Fred »

Was you database using an ASCII encoding ? We expect UTF8 IIRC
User avatar
holzhacker
Enthusiast
Enthusiast
Posts: 123
Joined: Mon Mar 08, 2010 9:14 pm
Location: "Mens sana in corpore sano"
Contact:

Re: PB 5.70 B4 - accentuation and MariaDB

Post by holzhacker »

Fred wrote:Was you database using an ASCII encoding ? We expect UTF8 IIRC
The database of this application (it is third party) is with Default Collation: latin1 - default collation, in the database and in the tables.

I made a change to: utf8_general_ci but unsuccessfully.

If there is any way to properly recover using the new library thank you for suggestions.

I would like to inform you that the constant #PB_Database_MySQL is referenced in the OpenDatabase help, but it is not defined.
Greetings and thanks!

Romerio Medeiros
romerio@gmail.com
#NULL
Addict
Addict
Posts: 1440
Joined: Thu Aug 30, 2007 11:54 pm
Location: right here

Re: PB 5.70 B4 - accentuation and MariaDB

Post by #NULL »

I don't know MariaDB but i think changing the collation doesn't convert your data. Also collation is for sorting etc. and the encoding of the data is flagged by character set instead. And changing the character set and converting the actual data in the database are 2 different things.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2810
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Re: PB 5.70 B4 - accentuation and MariaDB

Post by Num3 »

For future reference (almost 2 years too late :) ).

You can solve this by this with a simple a query every time you connect to the database for the 1st time (or disconnect and reconnect):

Code: Select all

query.s = "SET NAMES 'utf8' COLLATE 'utf8_general_ci';"
All queries after this will output correctly.

I tested with a converted to latin1 to utf8 database, that had the same problem, and it works. You can also set it to latin1

Code: Select all

query.s = "SET NAMES 'latin1' COLLATE 'latin1_swedish_ci';"
Post Reply