我已经读过ICU
库被用作backend
中的默认boost::locale
。如果是这样,我们可以在boost中使用UnicodeString
类型的ICU吗?有人可以提供一个例子..
编辑:这是我最后尝试过的..这里不需要存储到wstring,而是需要一个UnicodeString。
#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();
}