如果文件包含 £(井号),则 directory_iterator 会正确返回 utf8 字符序列\xC2\xA3
wdirectory_iterator 使用宽字符,但仍返回 utf8 序列。这是 wdirectory_iterator 的正确行为,还是我使用不正确?
AddFile(testpath, "pound£sign");
wdirectory_iterator iter(testpath);
TS_ASSERT_EQUALS(iter->leaf(),L"pound\xC2\xA3sign"); // Succeeds
TS_ASSERT_EQUALS(*iter, L"pound£sign"); // Fails
最佳答案
宽字符(wchar_t
对象)的编码是依赖于实现的。要使第二个语句(即 L"pound£sign")起作用,您可能需要更改基础语言环境。默认为“C”,它不知道井字符。十六进制值成功,因为这不需要将字形映射到特定编码中的值。
注意:为简洁起见,我将跳过标准 w.r.t wchar_t、扩展字符集等的确切措辞。
关于c++ - 什么 utf 格式应该 boost wdirectory_iterator 返回?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/810677/