【发布时间】:2013-04-23 01:05:30
【问题描述】:
我需要了解使用 '\uhhhh' 时 UNICODE_STRING_SIMPLE 宏的行为
我有以下代码:
cout<<"Char print out for À"<<endl;
SCAUString us = UNICODE_STRING_SIMPLE ("À");
cout<<"us.countChar32()="<<us.countChar32()<<endl;
for (int i=0; i<us.countChar32(); i++)
cout<<(int)us.charAt(i)<<" ";
输出: us.countChar32()=2 195 8364
但下面给出了不同的答案:\u00C0 是 À
cout<<"\nChar print out for \\u00C0"<<endl;
us = UNICODE_STRING_SIMPLE ("\u00C0");
cout<<"us.countChar32()="<<us.countChar32()<<endl;
for (int i=0; i<us.countChar32(); i++)
cout<<(int)us.charAt(i)<<" ";
这里的输出是: us.length()=1 192
谁能解释为什么会有差异?
我使用 ustream.h 写入文件:
testFile<<"5:"<< UNICODE_STRING_SIMPLE ("À"); // needs ustream.h
testFile<<endl;
testFile<<"6:"<< UNICODE_STRING_SIMPLE ("\u00C0"); // needs ustream.h
testFile<<endl;
testFile 是一个 ofstream。 当我打开我看到 5:À 但是 6 是错误的:6: 我在 Visual Studio 中打开了文本文件,这就是 VS 显示给我的实际字符。
【问题讨论】: