【发布时间】:2014-08-23 18:48:21
【问题描述】:
我对 D 中的 UTF8 字符串感到困惑。有人可以解释为什么下面的代码会给出不同的结果吗?为什么"abç"[2] == 'ç' 是false 而不是true?
string s = "abç";
for(int i = 0; i < s.length; i++)
{
dchar c = s[i];
writefln("%#x", cast(int)c);
}
writeln();
foreach(dchar c; s)
{
writefln("%#x", cast(int)c);
}
这段代码输出:
【问题讨论】: