p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   Cocoa (http://p2p.wrox.com/cocoa-192/)
-   -   UTF8 problem in getting data from mySQL (http://p2p.wrox.com/cocoa/79451-utf8-problem-getting-data-mysql.html)

ttvu May 18th, 2010 04:03 AM

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!


All times are GMT -4. The time now is 03:39 AM.

Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
2013 John Wiley & Sons, Inc.