【问题标题】:ICU characters don't match when using UNICODE_STRING_SIMPLE使用 UNICODE_STRING_SIMPLE 时 ICU 字符不匹配
【发布时间】: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 显示给我的实际字符。

【问题讨论】:

    标签: c++ unicode icu


    【解决方案1】:

    SCAUString 是什么?

    \u(单反斜杠)由您的编译器解释。也许编译器不认为目标代码页与 ICU 期望的相同?

    试试这个:

    printf("%x or %x?\n", (int)'À', (int)'\u00C0');

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-05-03
      • 2015-07-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-05-20
      • 1970-01-01
      • 2022-11-28
      相关资源
      最近更新 更多