宽窄字节字符串的转换

4、小作业:
熟练使用API方式及CA2W、CW2A、CT2W、CT2A类方式进行宽窄字符串的转换。多加练习才行!

#include <iostream>
#include "atlbase.h"
#include "atlstr.h"
using namespace std;
int main()
{
    //熟练使用API方式及CA2W、CW2A、CT2W、CT2A类方式进行宽窄字符串的转换。多加练习才行!
    //    1. 首先包含头文件:
    //    #include "atlbase.h"
    //    #include "atlstr.h"
    //    2.然后,工程设置成 unicode字符集:
    wcout.imbue(locale("chs"));
    char* p_a = "aaaa啊啊";
    CA2W a2wObj(p_a);
    wchar_t* p_www = (wchar_t*)a2wObj;
    wcout << p_www << endl;
    return 0;
}

 

posted on 2021-01-16 21:12  SakuraQAQ  阅读(211)  评论(0)    收藏  举报

导航