• 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: Working with Unicode
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Working with Unicode


  • Subject: Re: Working with Unicode
  • From: Ondra Cada <email@hidden>
  • Date: Fri, 31 Mar 2006 05:14:01 +0200

Julio,

On 31.3.2006, at 1:31, Julio Cesar Silva dos Santos wrote:

OK. Fine. But this is pure C and my goal is to use this string in Objective-C so I tried the following:
NSString * myString = [NSString stringWithCString:MY_CONSTANT encoding:NSASCIIEncoding];
NSLog("Test (Obj-C): %@",myString);

The string is all right. NSLog just tries to be smart. As for the escapes themselves, they are quite the same as in printf standard (i.e., '\r' is CR, to get just a backslash you have to put '\\' there), plus '\U...' for Unicodes.


In vast majority of cases the NSLog tricks are all right and it makes the output more readable. In the other cases when it bits your back (as happened to you) just try printf to see what's really there:

printf("Wanna see what there REALLY is in the string: %s",[myString UTF8String]);

or, if the worst comes to the worst

for (unsigned i=0,l=MIN([myString length],50);i<l;i++) {
  unichar cc=[myString characterAtIndex:i];
  printf("This is really weird: %d -- %d 0x%x '%C'\n",i,cc,cc,cc);
}
---
Ondra Čada
OCSoftware:     email@hidden               http://www.ocs.cz
private         email@hidden             http://www.ocs.cz/oc


_______________________________________________ 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: 
 >Working with Unicode (From: Julio Cesar Silva dos Santos <email@hidden>)
 >Re: Working with Unicode (From: John Stiles <email@hidden>)
 >Re: Working with Unicode (From: Julio Cesar Silva dos Santos <email@hidden>)

  • Prev by Date: NSTask secretly a class cluster?
  • Next by Date: $HOME not set?
  • Previous by thread: Re: Working with Unicode
  • Next by thread: Re: Working with Unicode
  • Index(es):
    • Date
    • Thread