• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
[SOVLED] Re: Converting from Unicode UTF-16 to 8bit MacCyrillic
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[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


References: 
 >Converting from Unicode UTF-16 to 8bit MacCyrillic (From: Horst Hoesel <email@hidden>)

  • Prev by Date: Re: Folder Action the Cocoa Way
  • Next by Date: Re: Helper Tool on FireWire
  • Previous by thread: Re: Converting from Unicode UTF-16 to 8bit MacCyrillic
  • Next by thread: NSOpenPanel isn't listening to me? I told it to only allow .zip and .xml!
  • Index(es):
    • Date
    • Thread