I have tried to convert the wchar_t string to NSString using initWithBytes but it always returns null.
i have tried the following code where my API returns NSString, but it is returning null always.
typedef struct CamList__Int_t
{
wchar_t DevicePath[MAX_CAM_DEV_SUPPORTED_INT][MAX_PATH];
UINT8 No_of_Cam_Devices;
}
CamList_Int;
-(NSString *)ConvertWcharStringToNSString :(const wchar_t *)inputString {
if (inputString == NULL) {
printf("inputString is Null, So there is No String Conversion taken Place!!!\r\n");
return NULL;
}
else {
printf("inputString: %s\r\n", inputString); //printing inputString for Debuging
return [ [NSString alloc] initWithBytes:inputString length:(wcslen(inputString) * sizeof(wchar_t)) encoding:NSUTF32LittleEndianStringEncoding ];
}
}
-(void) getConnectedDeviceName :(inout NSString *)deviceName {
CamList_Int CamDeviceListInt;
if(CreateCamDevicesLists(&CamDeviceListInt) == true) {
deviceName = [self ConvertWcharStringToNSString: CamDeviceListInt.DevicePath[0]];
}
}
So kindly help me out to resolve this issue.
Thanks in Advance