【发布时间】:2012-03-21 05:46:29
【问题描述】:
我正在尝试仅使用标准库而不是 Boost 或 Windows API 来读取 Visual C++ 2010 中的 UTF-8 文本文件。我将语言环境定义为:
std::locale utf8_locale(std::locale(), new std::codecvt_utf8<wchar_t>);
但这会导致以下编译器错误:
error C2661: 'std::locale::facet::operator new' : no overloaded function takes 3 arguments
error C2664: 'std::locale::locale(const char *,std::locale::category)' : cannot convert parameter 1 from 'std::locale' to 'const char *'
【问题讨论】:
-
你必须修复你的代码才不会出现编译错误。
-
向我们展示编译器错误和更多代码。
-
我在问题中添加了编译器错误
-
我使用了您的代码(谢谢!),但后来我意识到我认为您的第二个参数(新的 std::codecvt_utf8
)存在内存泄漏。我是 C++ 新手,所以我可能错了 -
除了你的问题你想使用
std::codecvt_utf8_utf16
标签: c++ visual-c++ utf-8