// The builtin encoding does not support GBK/GB2312
String(data: data, encoding: .GBK)
How do I convert data which is encoded in GBK/GB2312 (or anything else) to a string instance?
// The builtin encoding does not support GBK/GB2312
String(data: data, encoding: .GBK)
How do I convert data which is encoded in GBK/GB2312 (or anything else) to a string instance?
After some digging on the net, I myself found a solution:
NSStringEncoding gbkEncoding = CFStringConvertEncodingToNSStringEncoding(kCFStringEncodingGB_18030_2000);
NSString* newStr = [[NSString alloc] initWithData:data encoding:gbkEncoding];