Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NSString to wchar_t*?

I can't seem to find a good built-in way to convert an NSString to wchar_t... any tips on how to do this? Anything Apple exposes on the NSString class is for c-strings (char*) or for unichars, but nothing for wchar*.

like image 642
psychotik Avatar asked May 21 '09 06:05

psychotik


1 Answers

[urString cStringUsingEncoding:NSUTF16LittleEndianStringEncoding]

wchar_t is compiler specific. Assuming you wan the Win32 wchar_t, then UTF16 little ending encoded will do it. For Unix wchar_t you may need the NSUTF32 encoding family, with your platform of choice endianess.

like image 186
Remus Rusanu Avatar answered Sep 29 '22 07:09

Remus Rusanu