Saturday, May 14, 2011

NSString stringWithUTF8String example

stringWithUTF8String:

Returns a string created by copying the data from a given C array of UTF8-encoded bytes.
+ (id)stringWithUTF8String:(const char *)bytes
Parameters
bytes
NULL-terminated C array of bytes in UTF8 encoding.

Important: Raises an exception if bytes is NULL.
Return Value of stringWithUTF8String
A string created by copying the data from bytes.

Example of [NSString stringWithUTF8String]

Following code fragment shows how to use the method. The proper way to create NSString that contains unicode characters is to use stringWithUTF8String and the \u#### escape sequence, like this:
NSString *aString = [NSString stringWithUTF8String:"To be continued\u2026"];