Reputation: 1221
I want to convert the nsstring value into const char *.
NSString *s = @"יככעימבבגיננימ"; //Hebrew characters
const char *t = [s cStringUsingEncoding:NSUTF8StringEncoding];
NSLog(@"\n str = %s",t);
The console showed like this "יככעימבבגיננימ".
How to get the actual NSString value into const char*?
Thanks, loganathan
Upvotes: 2
Views: 3852
Reputation: 11542
It's just because %s
in NSLog
denotes ASCII string (plain-C 8 bit strings, to be precise), not UTF8.
What about trying the following?:
NSString *s = @"יככעימבבגיננימ"; //Hebrew characters
NSLog(@"\n str = %@",s);
You can log out UTF16 array, also:
const wchar_t *t = (const wchar_t*)[s cStringUsingEncoding:NSUTF16StringEncoding];
NSLog(@"\n str2 = %S",t);
Upvotes: 6