mySQL and Revolution encode.

Creating desktop or client-server database solutions?

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
jaguayo
Posts: 10
Joined: Sun Jun 14, 2009 8:12 pm

mySQL and Revolution encode.

Post by jaguayo » Sun Jun 10, 2012 12:34 pm

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

Klaus
Posts: 13878
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: mySQL and Revolution encode.

Post by Klaus » Sun Jun 10, 2012 12:51 pm

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

jaguayo
Posts: 10
Joined: Sun Jun 14, 2009 8:12 pm

Re: mySQL and Revolution encode.

Post by jaguayo » Sun Jun 10, 2012 3:11 pm

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

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: mySQL and Revolution encode.

Post by bangkok » Sun Jun 10, 2012 3:55 pm

In your code, before to do your insert, try :

Code: Select all

revExecuteSQL dbID, "SET NAMES 'utf8'"

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1236
Joined: Sat Apr 08, 2006 1:10 pm
Location: Zurich
Contact:

Re: mySQL and Revolution encode.

Post by BvG » Sun Jun 10, 2012 3:55 pm

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.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

jaguayo
Posts: 10
Joined: Sun Jun 14, 2009 8:12 pm

Re: mySQL and Revolution encode.

Post by jaguayo » Sun Jun 10, 2012 10:08 pm

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

Post Reply

Return to “Databases”