unicode和ASCII两种字符环境的区别

来源:互联网 发布:java数组输出在一行 编辑:程序博客网 时间:2024/05/05 15:03

#include <windows.h>

#include <tchar.h>

#include <sstream>

using namespace std;

 

#ifdef UNICODE

typedef wstring Astring;

typedef wostringstream OStringstream;

#else

typedef string Astring;

typedef ostringstream OStringstream;

#endif

 

 

int WINAPI _tWinMain( HINSTANCE hInstance,

                      HINSTANCE hPrevInstance,

                      PTSTR     lpCmdLine,

                      int       nCmdShow)

{

    PTSTR str = TEXT("你好");

    PTSTR message = TEXT("hello");

    int a = lstrlen(str);

    OStringstream out_str;

    out_str << "this is " << a << endl;

    Astring s = out_str.str();

    PCTSTR p = s.c_str();

    MessageBox( NULL, p, str, MB_OK );

    return 0;

}

原创粉丝点击