Converting wchar_t to Char
I need to convert:
wchar_t arr[20][32]
To
char arr[20][32]
The conversion is done in the DLL (written in C++) and I want the values of arr
to be displayed to the user in Windows Forms (written in C#).
Is it possible to display directly wchar_t
in a textbox or should I convert from wchar_t
to char
in the DLL and then from char
to string
in Windows Forms?
How is this conversion do开发者_如何学Gone?
If the conversion is being done in C++, then take a look at WideCharToMultibyte function, defined in and exported from kernel32
If the conversion is being done in C#, look at the System.Text.ASCIIEncoding.ASCII.GetBytes(string) function to get an ASCII representation of a unicode string.
精彩评论