• 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: Greg Guerin <email@hidden>
  • Date: Wed, 16 Sep 2009 12:44:53 -0700

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. 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.

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.

  -- GG

_______________________________________________

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: Johan Kool <email@hidden>
  • Prev by Date: Re: Debug-level messages don't appear in Console even after asl_set_filter()
  • Next by Date: Finding and NSView in a window
  • Previous by thread: Re: NSTableView scroll row by row (?)
  • Next by thread: Re: NSString vs. encoding
  • Index(es):
    • Date
    • Thread