[SOVLED] Re: Converting from Unicode UTF-16 to 8bit MacCyrillic
[SOVLED] Re: Converting from Unicode UTF-16 to 8bit MacCyrillic
- Subject: [SOVLED] Re: Converting from Unicode UTF-16 to 8bit MacCyrillic
- From: Horst Hoesel <email@hidden>
- Date: Sun, 25 Jun 2006 13:51:57 +0200
This can easily be solved via, what I call RTFHCS (read the fine
headers completely, stupid).
CFString encodings need to be converted before being used with NSString.
So with dataUsingEncoding:CFStringConvertEncodingToNSStringEncoding
(kCFStringEncodingMacCyrillic) everything is fine.
Thanks to Ricky for the off-list solution and for not saying RTFH :)
Trouble is the following (except for not getting any points for
pretty code :)
NSData* myRet; // should receive the input converted to 8 bit
MacCyrillic on exit
NSString* utf16String; // contains the text to convert
if ([utf16String
canBeConvertedToEncoding:kCFStringEncodingMacCyrillic] == YES) {
myRet = [utf16String dataUsingEncoding:kCFStringEncodingMacCyrillic];
} else {
myRet = [NSData dataWithBytes:"Cannot encode string in
MacCyrillic" length:sizeof("Cannot encode string in MacCyrillic")];
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden