Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
5 NSString *str = 6 [NSString stringWithUTF8String: 7 "some text in a C string"]; 8 const char *utf16 = 9 [str cStringUsingEncoding: NSUTF16StringEncoding]; 10 const char *utf32 = 11 [str cStringUsingEncoding: NSUTF32StringEncoding]; 12 const char *macRoman = 13 [str cStringUsingEncoding: NSMacOSRomanStringEncoding]; |
In OpenStep, two of the most common methods on NSString were -cString and +stringWithCString:. These converted between a C string and an Objective-C string. The problem with these methods was that C strings are not encoding aware.