unicode - 尝试使用 std::wcout << wstring-var 时出现错误 C2679; vc++ 2008 express

标签 unicode visual-c++-2008-express

在 vc++ 2008 express 中尝试 wcout wstring 时,我收到一条相当奇怪的错误消息:

error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::wstring' (or there is no acceptable conversion)



如果我理解正确,它会报告 wcout 不接受 wstring?我请人在 linux 下编译这段代码,它运行良好。我还在另一台装有 vc++ 2008 express 的计算机上尝试了相同的代码,但仍然失败。 vc++ 2008 中 std 的一个已知问题?
#include <iostream>

int main()
{
 std::wstring unicode_test = L"Unicode var";
 std::wcout << L"Unicode non-var" << std::endl;
 std::wcout << unicode_test << std::endl;    //<-- This line fails!
}

我正在使用 vc++ 2008 express sp1 以及 KB948127 之前的所有更新。我知道控制台需要更改代码页,但这甚至没有编译。谢谢。

最佳答案

您需要#include <string> .我不确定标准怎么说,但我很确定 <iostream>不需要导出所有 <string> ,如果有的话。

[编辑]至少 cplusplus.com甚至没有列出 string作为 <iostream> 中声明的类型.不,这不是标准,我知道...[/edit]

关于unicode - 尝试使用 std::wcout << wstring-var 时出现错误 C2679; vc++ 2008 express ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1439012/

相关文章:

service - 链接 : fatal error LNK1221: a subsystem can't be inferred and must be defined

c++ - 当我在 Visual C++ 中 sleep (1000)时出错,使 srand()工作

c++ - 如何在 Visual C++ 2008 Express Edition 中为我的程序设置图标?

string - 如何将字符串截断为最多 N 个字符?

html - 如何检测 C++ 字符串中的 "​"(unicode 的组合)

python - Flask - header 未转换为 unicode?

java - 如何在Java中删除字符串中Unicode杂项符号的Unicode十进制值

python - 使用内联脚本时在 Python 中将 unicode 字符打印到控制台的正确方法