- API方式
void TC2C(const PTCHAR tc, char * c) { #if defined(UNICODE) WideCharToMultiByte(CP_ACP, 0, tc, -1, c, wcslen(tc), 0, 0); c[wcslen(tc)] = 0; #else lstrcpy((PTSTR)c, (PTSTR)tc); #endif }
<span style="font-family: Arial, Helvetica, sans-serif;"></span><div class="line number14 index13 alt1" style="font-family: Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace; border-top-left-radius: 0px !important; border-top-right-radius: 0px !important; border-bottom-right-radius: 0px !important; border-bottom-left-radius: 0px !important; background-image: none !important; border: 0px !important; bottom: auto !important; float: none !important; height: auto !important; left: auto !important; line-height: 1.8em !important; margin: 0px !important; outline: 0px !important; overflow: visible !important; padding: 0px 1em !important; position: static !important; right: auto !important; top: auto !important; vertical-align: baseline !important; width: auto !important; box-sizing: content-box !important; min-height: inherit !important;">void charTowchar(const char *chr, wchar_t *wchar) { <span style="white-space:pre"> </span>int size = strlen(chr)+1; <span style="white-space:pre"> </span>MultiByteToWideChar( CP_ACP, 0, chr, <span style="white-space:pre"> </span>strlen(chr)+1, wchar, size/sizeof(wchar[0]) ); } </div>
- ATL宏
#include "atlconv.h" void func() { USES_CONVERSION; char *test = "i am a sucker"; WCHAR *conv = A2W(strPic1) ; }
unicode与多字节的字符串转换
最新推荐文章于 2024-04-30 11:41:33 发布