jason white
jason white

Reputation: 711

Conversion from UTF8 to Unicode in NSString iOS

I don't see any direct NSString function converting UTF8 to Unicode string? Do I need to use third party codes to do the conversion?

any ideas?

Upvotes: 0

Views: 651

Answers (1)

David Hoerl
David Hoerl

Reputation: 41662

Its pretty easy. First you get the string' length, [str length], then you get a pointer to the unichar bytes (unichar is UTF-16 more or less):

unichar unibuffer[length];
[str getCharacters:unibuffer range:NSRangeMake(0, length]];

Upvotes: 2

Related Questions