Convert wchar_t* to NSString
- by Sharath
Trying to convert const wchar_t * to NSString.
The following code only produces the first character. I've tried the different CFAllocator options as well but with no success.
Can anyone help me or point to how I can convert wchar_t * to NSString
const wchar_t *data = L"Hello World";
int l = wcslen(data);
CFStringRef c = CFStringCreateWithCharacters(kCFAllocatorSystemDefault,
(const UniChar *) data,l);
NSString *nStr = (NSString *)c; //This always gives me 'H'