Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4470127
  • 博文数量: 356
  • 博客积分: 10458
  • 博客等级: 上将
  • 技术积分: 4734
  • 用 户 组: 普通用户
  • 注册时间: 2008-03-24 14:59
文章分类

全部博文(356)

文章存档

2020年(17)

2019年(9)

2018年(26)

2017年(5)

2016年(11)

2015年(20)

2014年(2)

2013年(17)

2012年(15)

2011年(4)

2010年(7)

2009年(14)

2008年(209)

分类: C/C++

2008-04-09 16:56:54

#include "stdafx.h"
#include <afxwin.h>
//#include

//#include

#include <iostream>
using namespace std;
int main( void )
{

    CString str( L"%First Second#Third" );
    CString resToken;
    int curPos= 0;
    resToken= str.Tokenize(L"% #",curPos);
    while (resToken != L"")
    {
        wcout.imbue(locale("chs")); //设置locale

        wcout<< resToken << endl;
        char buf[20]={'\0'};
        WideCharToMultiByte(NULL,CP_ACP,resToken,resToken.GetLength(),buf,resToken.GetLength(),NULL,NULL);
        cout << buf << endl;
        resToken= str.Tokenize(L"% #",curPos);
    };
    
    wchar_t text= L'我';
    wcout.imbue(locale("chs"));
    wcout <<"this is "<<text << endl;

    return 0;
}

输出单个中文字符是在网上查的  整个字符串输出光用wcout是不行的 要转成单字节的字符串

代码不想注释了  看结果就OK

00,3A9,B58
First
00,3AF,1E8
Second
00,DF1,5D0
Third
this   is   我

阅读(5513) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~