2010/04/26

To Use Spilit with Wide Character

Common

  • Use wchar_t instead of char.
  • Set your locale if default C locale is not enough to express your language.
  • Use std::wstring instead of std::string.
  • Use std::wiostream family instead of std::iostream

Of course, you can use std::basic_string<...> and std::basic_stream<...> family directly, or use typedef.

Lex

  • Use boost::spirit::lex::token_def<std::wstring, wchar_t> instead of token_def<>.
  • Write regular expressions in wide characters.
  • Use boost::spirit::lex::lexertl::token<wchar_t const*> instead of token<char const*>.

Qi

  • Use boost::spirit::qi::symbols<wchar_t,std::wstring instead of symbols<char,std::string>
  • Write grammar rules in wide characters.
  • Use std::wstring::iterator instead of std::string::iterator
  • As skipper also requires wide character version, replace skipper parameter of phrase_parse().

Note

  • As the argument of boost::spirit::qi::rule<...>::name() is not depends on character set, it is only single byte characters.

No comments:

How to set parameters to debugging program on Visual Studio 2019 with CMake

Solution: MSDN Sometimes the "Debug and Launch Settings for CMake" bottun is disabled. In this case, change to the target view. ...