REAL Software Forums

The forum for REAL Studio and other REAL Software products.
[ REAL Software Website | Board Index ]
It is currently Sun Aug 01, 2010 12:08 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Funny characters - how to handle
PostPosted: Sat Apr 07, 2007 8:12 am 
Offline
User avatar

Joined: Sat Oct 01, 2005 4:47 am
Posts: 68
Location: Melbourne, Australia
Hope someone can help. I've written a converter program whereby I transfer data from one MySql database (Wordpress) to another MySql database (Drupal). Both are blogging type packages (Drupal more a CMS).

My problem is with funny accented or weird characters. The characters of concern are curly quotes and unusual single quotes which can't be typed on my Windows keyboard.

The following piece of text:-

Code:
“Mares eat oats–and does eat oats—and…little lambs eat ‘ivy’.”

turns into this at the destination database:-
[code]
“Mares eat oats–and does eat oats—and…little lambs eat ‘ivy’.â€

_________________
Steve
rb2010 r1 Windows Vista.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 07, 2007 11:01 am 
Offline

Joined: Sat Oct 01, 2005 5:19 pm
Posts: 2110
that's an Encoding issue


Top
 Profile  
 
 Post subject:
PostPosted: Sat Apr 07, 2007 1:05 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 8130
Location: Portland, OR USA
Seems to me that strings coming back from mySql (at least using the old plugin, I haven't checked this on the new one) have undefined encoding. I had to explicitly tell RB that they were utf8.
Code:
someString= DefineEncoding(someString, Encodings.UTF8)

Tim


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 08, 2007 4:54 am 
Offline
User avatar

Joined: Sat Oct 01, 2005 4:47 am
Posts: 68
Location: Melbourne, Australia
I'm going around in circles now. When I enter the text string containing curly quotes via a Wordpress blog, it's saved and the viewing of the text (using Wordpress) is as per initial input - correctly showing the curly quotes. When checking the MySql database, for that particular field, the text has changed to show weird characters in place of the curly quotes. So obviously Wordpress is doing something in order to correctly display the text.

Now my program, for all intents and purposes is merely copying that particular field and inserting it into another MySql database.

I've noticed that the Wordpress MySql database, for the particular table and field is marked as "Latin1_sweedish_ci". My target database (Drupal MySql) is "utf8_general_ci".

I am retrieving the particular field like so:-
Code:
strBody= rstSource.Field("post_content").StringValue

So the variable "strBody" now contains the contents of the source field, which contains the altered characters (characters in place of curly quotes).

I've tried various attempts at using 'Encodings' but nothing seems to work. Can someone simply list the steps required.

Any advice greatly appreciated.
My Realbasic Program

_________________
Steve
rb2010 r1 Windows Vista.


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 04, 2007 8:14 pm 
Offline
User avatar

Joined: Sat Oct 01, 2005 4:47 am
Posts: 68
Location: Melbourne, Australia
The answer:

After making a connection, send the following command to MySql:

db.SqlExecute("SET NAMES 'utf8';") // if unicode

or

db.SqlExecute("SET NAMES 'latin1';") // if Latin1.

For a full understanding of character codes the reference manual over at the MySql is a good source to start with.

Even though RB, by default, works with utf8, still send the command to MySql, if MySql is expecting utf8.

_________________
Steve
rb2010 r1 Windows Vista.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group