我的设备装了WINCE,有一个串口跟电脑连接,电脑发送数据给WINCE,接收到的是乱码,不知道怎么解决?
------解决方案--------------------
多字节和宽字符之间转换的函数:mbstowcs, mbtowc, wcstombs, wctomb.
mbstowcs---Convert a multi-byte(ANSI) string to wide character stirng(Unicode).
wcstombs---Convert a wide character string to multi-byte string.
WCHAR szwcBuffer[100];
char szBuffer[100];
char* lpszConvert = "ANSI String to convert ";
WCHAR* lpszwcConvert = _T( "Unicode string to convert ");
int nChars;
nChars = mbstowcs(szwcBuffer, lpszConvert, 100);
nChars = wcstombs(szBuffer, lpszwcConvert, 100);
//MultiByteToWideChar, WideCharToMultByte. //用在code page(编码页)
相关函数(ANSI Function, Unicode Function;):strcpy, wcscpy; strcat, wcscat; strcmp, wcscmp;
strlen, wcslen; strchr, wcschr; strstr, wcsstr; _strrev, _wcsrev;
//Convert an ANSI character to Unicode.
//set the high byte in the Unicode character to zero and copy the ANSI character into the low byte
WCHAR wC;
char c = 'C ';
wC = MAKEWORD(c, 0);