Unicode 与多字节编码

int _tmain(int argc, _TCHAR* argv[])
{
 //定义LPWSTR 类型的宽字符串
 LPWSTR szUnicode = L"This is a Unicode  String;";
 //定义LPSTR 类型的窄字符串
 LPSTR szMutliByte = "This is not a Unicode String;";
 //定义 LPTST 类型的自适用字符串
 LPTSTR szString = TEXT("This string is Unicode or not depends on the option.");
 //使用W版本的API 函数,以宽字符串为参数
 MessageBoxW(NULL, szUnicode, L"<字符编码1>", MB_OK);
 //使用A版本的API 函数,以窄字符串为参数
 MessageBoxA(NULL, szMutliByte,"<字符编码2>", MB_OK);
 //根据编译条件自动选择A版本或W版本的API函数,采用相适应的字符串类型为参数
MessageBox(NULL, szString, TEXT("<字符编码3>"), MB_OK);
 return 0;

}

 

posted @ 2015-09-23 17:05  苏镡  阅读(231)  评论(0编辑  收藏  举报