ohho ohho - 2 years ago 112
Objective-C Question

Chinese char* conversion to NSString on iOS?

I'd like to convert GB encoded

char *
NSString *

char *str = ...
size_t len = ...

NSString *s = [[NSString alloc] initWithBytes:str length:len encoding:???];

is available. I wonder it there an predefined encoding for GB Chinese characters? similar to kCFStringEncodingGB_2312_80, defined in

Answer Source

You can use the CF string encodings with NSString; from Apple's docs:

Additional encodings are defined in String Programming Guide for Core Foundation (see CFStringEncodingExt.h); these encodings can be used with NSString by first passing the Core Foundation encoding to the CFStringConvertEncodingToNSStringEncoding function.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download