*unicode字符输出有关问题*

**unicode字符输出问题****

TCHAR   aa[10];//unicode版
aa[0]= '辈 ';
aa[1]= '鲍 ';
如何将aa[0]输出呢?
cout < <aa[0] < <endl;//这样输出不了 '辈 '这个unicode字符啊??输出的是52428这个数字!!
要怎么才能通过aa[0]将 '辈 '字符输出??

------解决方案--------------------
TCHAR 是unsigned int型的
------解决方案--------------------
cout 不行,好像是 wcout
------解决方案--------------------
C++中使用wchar_t表示Unicode字符
cout输出char型, wcout输出wchar_t
有string, 也有wstring

要输出wchar_t,需要设置国、语言和编码
locale loc( "CHS ");//
wcout.imbue(loc);
wchar_t wc = L '就 ';
wchar_t* ws = L "wstring宽 ";
wstring ws2 = L "wstring宽宽 ";
wcout < < wc < < endl < < ws < < endl < <ws2 < < endl;
将Unicode字符输出到文件使用wofstream
wofstream fout;
fout.open( "funcForeign.txt ");
fout.imbue(loc);
fout < <L '\xFEFF ';
fout < < wc < < endl < <ws < < endl;
这样输出的Unicode字符会被转换为ANSI字符,中文Unicode字符会被转换为GB2312字符。

如果需要使用Unicode保存字符,需要修改输入输出流的缓冲区。
std::wofstream fout;
fout.open( "D:\\wordHistory.ini ", ios_base::out | ios_base::trunc | ios_base::binary);
wchar_t buffer[512];
wchar_t text[512];
fout.rdbuf()-> pubsetbuf(buffer, (streamsize)512); // 修改
wchar_t bom = L '\xFFFE ';
fout.write(&bom, 1);
fout < < L "wstring宽宽 " < < endl;

------------
参考MSDN
http://msdn2.microsoft.com/en-us/library/tzf8k3z8(VS.80).aspx

------解决方案--------------------

setlocale(LC_ALL, "chinese ");
wchar_t wc = L '就 ';
//wcout < <wc < <endl;

wprintf(L "%c\n ", wc);