Does anyone know How to convert ISO-8859-1 encoded string into UTF-8 string or into NSString in Objective C ?
thanks.
Say you have your ISO-8859-1 encoded string in a varaible isoString
of type const char*
, then you can create an NSString instance like this:
NSString* str = [[NSString alloc]
initWithCString: isoString encoding: NSISOLatin1StringEncoding];
Note: Latin-1 and ISO-8859-1 encoding are the same.
With the following code, you can convert it to a UTF-8 encoded C string if needed:
const char* utf8String = [str UTF8String];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With