mySQL and Revolution encode.
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
mySQL and Revolution encode.
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
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.
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!
You will need to convert the strings from the database before putting them into LiveCode fields.
And welcome to the forum
Best
Klaus
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!
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.
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
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.
In your code, before to do your insert, try :
Code: Select all
revExecuteSQL dbID, "SET NAMES 'utf8'"
-
- VIP Livecode Opensource Backer
- Posts: 1236
- Joined: Sat Apr 08, 2006 1:10 pm
- Location: Zurich
- Contact:
Re: mySQL and Revolution encode.
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):
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):
Note the last line, that's one way to convert utf8 into rev-internal encoding.
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 & "'")
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
Various teststacks and stuff:
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
http://bjoernke.com
Chat with other RunRev developers:
chat.freenode.net:6666 #livecode
Re: mySQL and Revolution encode.
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
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