FROM : Horst Hoesel
DATE : Sun Jun 25 13:51:57 2006
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")];
> }
>
DATE : Sun Jun 25 13:51:57 2006
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")];
> }
>
| Related mails | Author | Date |
|---|---|---|
| Horst Hoesel | Jun 23, 12:02 | |
| Ricky Sharp | Jun 23, 14:18 | |
| Horst Hoesel | Jun 25, 13:51 |






Cocoa mail archive

