Re: Working with Unicode
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