【ios】 怎样让字符串以ios-8859-1的编码方式编码
怎样让字符串以ios-8859-1的编码方式编码
在的enum没有这个 只用一个NSISOLatin1StringEncoding 是这个吗?
各位大侠帮帮忙!
[解决办法]
ios-8859-1 iphone nsstring
[解决办法]
You can use NSString's getCString:maxLength:encoding: method, like this:
char converted[([string length] + 1)];
[string getCString:converted maxLength:([string length] + 1) encoding: NSISOLatin1StringEncoding];
NSLog(@"%s", converted);
Once you have this, you can then re-initialize an NSString instance from that same encoding using the stringWithCString:encoding: class method:
NSString *converted_str = [NSString stringWithCString:converted encoding:NSISOLatin1StringEncoding];