According to MSDN ([1],[2]) we have this definitions:
#if !defined(_NATIVE_WCHAR_T_DEFINED)
typedef unsigned short WCHAR;
#else
typedef wchar_t WCHAR;
#endif
typedef WCHAR OLECHAR;
typedef OLECHAR* BSTR;
So BSTR
is of type wchar_t*
or unsigned short*
, or a null terminated 16-bit string.
From what I see from the documentation of Platform::String
the constructor accepts a null-terminated 16-bit string as const char16*
While char16
is guaranteed represent UTF16, wchar
is not.
UPDATE: As Cheers and hth. - Alf
pointed out the line above isn't true for Windows/MSVC. I couldn't find any information on whether it is safe to cast between both types in this case. Since both wchar_t
and char16_t
are different integrated types I would still recommend to use std::codecvt
to avoid problems.
So you should use std::codecvt
to convert from wchar_t*
to char16_t*
and pass the result to the constructor of your Platform::String
.