//们关于 unicode 输出 输入 有关问题

//请教高手们关于 unicode 输出 输入 问题


#include   <iostream>
#include   <fstream>
#include   <string>
#include   <windows.h>
#include   <stdio.h>
using   namespace   std;

int   main()
{
wstring   filename; //先在C盘根目录建“哈哈.txt”文件。
wcin> > filename; //输入:C:\哈哈.txt
try
{
wifstream   wif(filename.c_str());]

if(!wif) //文件打不开的,调试时看   filename   就知道,乱码了
throw(ios::failure(wstring( "Failed   to   open   input   file   ")+filename));
//   上面那句的构造异常怎么办?   我没找到支持   wstring     的异常类

wcout < <TEXT( '哈 '); //这句不输出,为什么?

cout < < '   a ' < <endl; //输出   8289   怎么解释?
}
catch(exception&   ex)
{
wfstream   errout(wstring(TEXT( "LogErr.txt ")).c_str(),ios::app);
errout < <endl < <ex.what() < <endl;
errout.close();
}
}

但要是把   wstring,   wcin,   wcout   都换成     string,   cin,   cout   。那么字符串里的值正确,但文件(中文文件名的)打不开,为什么?




------解决方案--------------------
在我机器上,怎么中文文件名都打得开的嘛。
------解决方案--------------------
推荐一本书给楼主 <windows高级编程指南> 里面有专门讲UNICODE的章.
------解决方案--------------------
好像 不关UNICODE的事

------解决方案--------------------
首先,确定一下Windows的命令提示符窗口使用的字符集是什么?
一般情况下,它使用的是GBK,就是ASC码, 他怎么会处理UNICODE呢?

看看下面的语句能否正确执行
wcou < < L "wout正确执行wcout " < < endl;
如果我没猜错,第一个 "wcout "输出了,以后的字符都没有了.

你可以跟踪一下上面语句的输出过程,在某一个语句的时候,他忽略了大于255的字符.

C++库里,提供了wchar_t和char字符串的转换函数.

http://community.****.net/Expert/topic/5667/5667798.xml?temp=9.151858E-02
------解决方案--------------------
add :
wcout.imbue( locale( "chs ") );