• 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
Re: NSString vs. encoding
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSString vs. encoding


  • Subject: Re: NSString vs. encoding
  • From: Johan Kool <email@hidden>
  • Date: Wed, 16 Sep 2009 13:13:07 -0700


Op 16 sep 2009, om 12:44 heeft Greg Guerin het volgende geschreven:

Johan Kool wrote:

NSString *stringA = @"J\\303\\270ha\\314\\212n\\040i\\314\\210s\ \040Li\ \314\\200e\\314\\201\\306\\222";
NSLog(@"stringA %@ (expected Jøhån ïs Lìéƒ)", stringA);


You're doing it wrong.

I know. :-) Hence my post to the list...

NSNonLossyASCIIStringEncoding expects one escaped unit per Unicode code-point. It doesn't parse "multi-byte" forms like "\\303\\270", which I assume is intended to be something like an octal-escaped UTF8 encoding.

I think that is indeed what it is: octal-escaped UTF8 encoding.

To get a sense for what it wants as input, I recommend that you create a test with some hard-wired strings, then convert to bytes using the NSNonLossyASCIIStringEncoding, and dump the resulting ASCII text. Or you could use TextEdit.app and save or open as non- lossy ASCII.

I have been trying many combinations of encodings/decodings, but without the intended result. I do know what NSString wants, but that's not what I have. I have stringA as shown, and I have to somehow morph it into something usable. Basically I need NSString to interpret the characters a second time, but NSString seems to do all it can to keep it as is. Normally, that's indeed what I want, but not now...


Johan

---
http://www.johankool.nl/

KOOLISTOV - Software for Mac and iPhone
http://www.koolistov.net/




_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSString vs. encoding
      • From: Joar Wingfors <email@hidden>
    • Re: NSString vs. encoding
      • From: "Stephen J. Butler" <email@hidden>
References: 
 >Re: NSString vs. encoding (From: Greg Guerin <email@hidden>)

  • Prev by Date: Re: Finding and NSView in a window
  • Next by Date: Re: NSString vs. encoding
  • Previous by thread: Re: NSString vs. encoding
  • Next by thread: Re: NSString vs. encoding
  • Index(es):
    • Date
    • Thread