0

我已阅读该ICUbackendboost::locale. 如果是这样,我们可以UnicodeString在 boost 中使用 ICU 的类型吗?有人可以举个例子吗..

编辑:这是我最后尝试的。在这里,我需要一个 UnicodeString,而不是存储到 wstring。

#include <boost/locale.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/fstream.hpp>
#include <fcntl.h>
#include <io.h>
int main()
{

    boost::locale::localization_backend_manager my = boost::locale::localization_backend_manager::global();
    my.select("icu");



    _setmode(_fileno(stdout), _O_WTEXT); // for output

    std::locale::global(boost::locale::generator(my).generate(""));


    boost::filesystem::path::imbue(std::locale());
    boost::filesystem::wifstream hello("I:\\a.txt");//Contents of this file can be strings in regional language

    if (hello.is_open())
    {

        for (std::wstring s; getline(hello, s); )
        {
            std::wcout << s;//need a UnicodeString instead of s.
            std::wstring cmd = L"I:\\";
            cmd += s;
            boost::filesystem::wifstream hello1(cmd);
            if (hello1.is_open())
            {
                std::wstring i;
                while(getline(hello1,i))
                    std::wcout << i;
            }
            hello1.close();

        }
    }
    hello.close();
}
4

0 回答 0