View Single Post
  #1 (permalink)  
Old May 18th, 2010, 04:03 AM
ttvu ttvu is offline
Registered User
 
Join Date: May 2010
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default UTF8 problem in getting data from mySQL

I'm programming in Objective-C and use mySQL as database.
I added MCPKit Framework (to facilitate mySQL connection).
After successfully connected to mySQL, I had problem with data display on table view. My Vietnamese text don't display properly! For example: "Nguyễn Thị Hằng" appears as "Nguy?n Thị H?ng".
In AppleScript, I would easily include: --default-character-set-UTF8. What would be alternative way in Objective-C?

For reference, my code is as follow:

MCPConnection *db=[MCPConnection alloc];
MCPResult *result;
NSArray *theColNames;
db = [db initToHost:@"127.0.0.1" withLogin:@"root" usingPort:3306];
[db setPassword:@""];
NSLog(@"Connect: %d", [db connect]);
NSLog(@"SelectDB: %d", [db selectDB:@"MySystem"]);
if ([db isConnected])
{
result = [db queryString:@"select BookName, Type, Author from tbl_Book"];
...
}

Many thanks for your soon reply!
Reply With Quote