我的节目不承认中文.如何使用精神来认识中国人?我使用wstring并将其转换为utf-16.
这是我的头文件:
#pragma once
#define BOOST_SPIRIT_UNICODE
#include <boost/spirit/include/qi.hpp>
#include <string>
#include <vector>
#include <map>
using namespace std;
namespace qi = boost::spirit::qi;
namespace ascii = boost::spirit::ascii;
typedef pair<wstring,wstring> WordMeaningType;
typedef vector<WordMeaningType> WordMeaningsType;
typedef pair<wstring,WordMeaningsType> WordType;
typedef vector<WordType> WordListType;
struct WordPaser
:qi::grammar<wstring::iterator,WordListType(),ascii::space_type >
{
public:
qi::rule<wstring::iterator, wstring(),ascii::space_type> mRuleWordPart;
qi::rule<wstring::iterator, wstring(),ascii::space_type> mRuleWordMeaning;
qi::rule<wstring::iterator, wstring(),ascii::space_type> mRuleWord;
qi::rule<wstring::iterator, WordMeaningType(),ascii::space_type> mRulePM;
qi::rule<wstring::iterator, WordMeaningsType(),ascii::space_type> mRulePMs;
qi::rule<wstring::iterator, WordType(),ascii::space_type> mRuleCurWPM;
qi::rule<wstring::iterator, WordListType(),ascii::space_type> mRuleEntrence;
wstring mCurWord;
wstring mCurWordPart;
wstring mCurWordMeaning;
WordMeaningType mCurPM;
WordMeaningsType mCurPMs;
WordType mCurWPM;
WordPaser();
}; …Run Code Online (Sandbox Code Playgroud)