Convert wchar_t to CFStringref

I have wchar_t * which I need to use for a function that needs CFStringref

I tried using CFStringCreateWithCharacters but I am not getting with anyone.

So, if I have:

 wchar_t * widecharvar = L"some value"; CFStringRef stringref; 

How to convert and copy widecharvar to stringref ? This value will be used in SecRequirementCreateWithString()

thanks

+4
source share
1 answer

I do it head to head; if he has problems, comment and I will really check it out.

 // Check our byte order. Assuming we made the string as in your example CFStringEncoding encoding = (CFByteOrderLittleEndian == CFByteOrderGetCurrent()) ? kCFStringEncodingUTF32LE : kCFStringEncodingUTF32BE; int widecharvarLen = wcslen(widecharvar); CFStringRef string = CFStringCreateWithBytes(NULL, widecharvar, (widecharvarLen * sizeof(wchar_t)), encoding, false); 

This last false means that the line does not include the specification (bytes), which is the line that I assume you are dealing with.

+4
source

Source: https://habr.com/ru/post/1394487/


All Articles