With boost version 1.60 I could use #define BOOST_SPIRIT_UNICODE and boost::spirit::unicode::char_ to process UTF-8 input strings without any further preprocessing. With boost version 1.72 this fails with an exception.
The solution seems to be to use boost::u8_to_u32_iterator and let spirit work with wide strings. But why did it work so flawlessly in the earlier version and if possible how can I reactivate the old behavior?
Here is some sample code:
#define BOOST_SPIRIT_UNICODE
#include <boost/spirit/include/qi.hpp>
int main()
{
typedef std::string::const_iterator iterator_type;
namespace qi = boost::spirit::qi;
namespace unicode = boost::spirit::unicode;
std::string input("\"Test ⏳\"");
qi::rule<iterator_type, std::string(), unicode::space_type> quoted_string = qi::lexeme['"' >> +(unicode::char_ - '"') >> '"'];
iterator_type iter = input.begin();
iterator_type end = input.end();
std::string output;
bool r = phrase_parse(iter, end, quoted_string, unicode::space, output);
if (r && iter == end)
std::cout << "successfully parsed " << input << " to " << output << std::endl;
else
std::cout << "failed to parse " << input << std::endl;
return 0;
}