Как использовать boost :: spirit для разбора UTF-8?
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#define BOOST_SPIRIT_UNICODE // We'll use unicode (UTF8) all throughout
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/qi_parse.hpp>
#include <boost/spirit/include/support_standard_wide.hpp>
void parse_simple_string()
{
namespace qi = boost::spirit::qi;
namespace encoding = boost::spirit::unicode;
//namespace stw = boost::spirit::standard_wide;
typedef std::wstring::const_iterator iterator_type;
std::vector<std::wstring> result;
std::wstring const input = LR"(12,3","ab,cd","G,G\"GG","kkk","10,\"0","99987","PPP","你好)";
qi::rule<iterator_type, std::wstring()> key = +(qi::unicode::char_ - qi::lit(L"\",\""));
qi::phrase_parse(input.begin(), input.end(),
key % qi::lit(L"\",\""),
encoding::space,
result);
//std::copy(result.rbegin(), result.rend(), std::ostream_iterator<std::wstring, wchar_t> (std::wcout, L"\n"));
for(auto const &data : result) std::wcout<<data<<std::endl;
}
Я изучил этот постКак использовать Boost Spirit для разбора китайского (unicode utf-16)? и следуйте инструкциям, но не можете разобрать слова "你好"
ожидаемые результаты должны быть
12,3 ab, cd G, G \ "GG kkk 10 \", 0 99987 PPP 你好
но фактические результаты 12,3 а.б., кд G, G \ "GG ккк 10 \", 0 99987 ППС
Не удалось разобрать китайские слова "你好"
ОС win7 64bit, мой редактор сохранил слова как UTF-8