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

NSString vs. unicode encoding


  • Subject: NSString vs. unicode encoding
  • From: Johan Kool <email@hidden>
  • Date: Tue, 15 Sep 2009 21:04:47 -0700

Dear list,

I need to work with strings as in stringA. (I don't have much choice, but to have it in a NSString at the start.) I want to have the readable output "hello world".

NSString *stringA = @"hello\040world";
NSString *stringB =  [NSString stringWithUTF8String:"hello\040world"] ;

// This works, so I know NSString can deal with the encoding I have in stringA
NSLog(stringB);


// This does not work (as expected)
NSLog([NSString stringWithUTF8String:[stringA UTF8String]]);

// Nor does this work
NSLog([NSString stringWithUTF8String:[[stringA dataUsingEncoding:NSUTF8StringEncoding] bytes]]);


// Or this for that matter
NSLog([NSString stringWithUTF8String:[[stringA dataUsingEncoding:NSASCIIStringEncoding] bytes]]);


Any suggestions for how I could do this? I haven't been able to locate much about this in the documentation or by searching Google.

Thanks!!

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. unicode encoding
      • From: Shawn Erickson <email@hidden>
    • Re: NSString vs. unicode encoding
      • From: Jens Alfke <email@hidden>
  • Prev by Date: LSOpenFromURLSpec error
  • Next by Date: Re: NSOperation and lazy loading
  • Previous by thread: LSOpenFromURLSpec error
  • Next by thread: Re: NSString vs. unicode encoding
  • Index(es):
    • Date
    • Thread