Page 1 of 1

mySQL and Revolution encode.

Posted: Sun Jun 10, 2012 12:34 pm
by jaguayo
Hello:

I have a mySQL Database in Spanish.
When I try to transfer data from Revolution to the mySQL disappear the accents.
The database run OK when I import datas from a text file created with Revolution. I put in the import the "Western MacOSRoman" encode options.
How put I this option in Revolution.???

Un saludo.

Joseba

Re: mySQL and Revolution encode.

Posted: Sun Jun 10, 2012 12:51 pm
by Klaus
Hola Joseba,

what platform are you on, Mac or Win? Mac, I guess.
How is the database encoded? MacOSRoman? ISO-xxx? UTF8? UTF16?
This is the key question! :D

You will need to convert the strings from the database before putting them into LiveCode fields.

And welcome to the forum :)


Best

Klaus

Re: mySQL and Revolution encode.

Posted: Sun Jun 10, 2012 3:11 pm
by jaguayo
Hola Klaus:

I work in Mac Platform.
The database mySQL is encoded in UTF8.
I need to put datas in the database from my Revolution Stack. The datas are in a Revolution field and when I put them in a mysql field the accents dissapear.

Thanks.

Joseba

Re: mySQL and Revolution encode.

Posted: Sun Jun 10, 2012 3:55 pm
by bangkok
In your code, before to do your insert, try :

Code: Select all

revExecuteSQL dbID, "SET NAMES 'utf8'"

Re: mySQL and Revolution encode.

Posted: Sun Jun 10, 2012 3:55 pm
by BvG
Basically, when you enter stuff, it should be entered correctly and converted automatically. when you get it out however, you need to decode the strings properly.

So how do you do it?

a basic example would be (untested):

Code: Select all

put revopendatabase("mysql",blah,blah") into theConnId
revexecutesql theConnID, ("insert into myTable value myColumn= '" & field 1 & "'")
If you now look into your database (not by getting data out of the database into LC again, but for example with myphpadmin), you should see the non-ascii characters retained properly, if this step fails in your project, try to use a simple test code like the one above.


After you got entry working properly, you can get the data out of the DB again. To show correctly entered text in lc, you need to decode it, something like this (untested):

Code: Select all

put revopendatabase("mysql",blah,blah") into theConnId
put revDataFromQuery( theConnID, "select myColumn from myTable") into theData
put unidecode(uniencode(theData,"utf8")) into field 1
Note the last line, that's one way to convert utf8 into rev-internal encoding.

Re: mySQL and Revolution encode.

Posted: Sun Jun 10, 2012 10:08 pm
by jaguayo
Hello:

The problem is solved.
I put revExecuteSQL dbID, "SET NAMES 'macroman'" and now appears the accent in the field of mySQL database.

Thank you very much to all. (Eskerrik asko)

Joseba