• 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
Converting from Unicode UTF-16 to 8bit MacCyrillic
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Converting from Unicode UTF-16 to 8bit MacCyrillic


  • Subject: Converting from Unicode UTF-16 to 8bit MacCyrillic
  • From: Horst Hoesel <email@hidden>
  • Date: Fri, 23 Jun 2006 12:02:11 +0200

Hi all,

for a small tool I need to convert user entered Russian text into MacCyrillic characters. User input is into a NSTextField output is via the scrap. (Yep, using Carbon, because I found no way to put old style 8 bit characters into the pasteboard without evoking some kind of unwanted conversion. But that is not my trouble)

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")];
}


myRet will contain "\u041c\u0435\u0434\u0438\u0430" for an utf16string of "Медиа". This is a valid representation of the source, but surely not the conversion I'd expect. I had expected it to contain 5 8 bit characters based on the MacCyrillic encoding of "Медиа".

What am I doing wrong?

Any ideas and hints appreciated.

TIA,
Horst

--
Horst Hoesel
VierZwo Software GmbH
Ruebezahlstr. 20
81739 Muenchen
Germany


_______________________________________________ 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
  • Follow-Ups:
    • [SOVLED] Re: Converting from Unicode UTF-16 to 8bit MacCyrillic
      • From: Horst Hoesel <email@hidden>
    • Re: Converting from Unicode UTF-16 to 8bit MacCyrillic
      • From: Ricky Sharp <email@hidden>
  • Prev by Date: NSSearchField with bindings: how to get notifications
  • Next by Date: NSOpenPanel isn't listening to me? I told it to only allow .zip and .xml!
  • Previous by thread: NSSearchField with bindings: how to get notifications
  • Next by thread: Re: Converting from Unicode UTF-16 to 8bit MacCyrillic
  • Index(es):
    • Date
    • Thread