【问题标题】:How can I use SimpleIni to return wchar_t and then convert to std::wstring?如何使用 SimpleIni 返回 wchar_t 然后转换为 std::wstring?
【发布时间】:2011-05-20 17:16:16
【问题描述】:

SimpleIni Documentation 说支持 wchar_t 但我不明白如何使用它。这是我尝试过的:

CSimpleIniCaseW ini;
ini.LoadFile("myapp.ini");
std::wstring test(ini.GetValue("testsection", "testkey", ""));

错误 C2664: 'CSimpleIniTempl::GetValue' : 无法将参数 1 从 'const char [12]' 到 'const wchar_t *'

【问题讨论】:

    标签: c++ visual-c++


    【解决方案1】:

    你需要将你的字符串指定为 L"testsection"

    【讨论】:

    • 好的,现在我不再收到那个错误了,但是 wstring 测试是空的。
    • 问题在于 ini 文件的编码。仅当我将 ini 文件保存为 ANSI 时才有效。
    猜你喜欢
    • 1970-01-01
    • 2012-02-13
    • 1970-01-01
    • 2017-12-12
    • 2013-07-28
    • 2015-09-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多