Re: UTF-8 support in Spirit::Qi

Joel de Guzman <[email protected]> Tue, 23 Nov 2021 07:13:06 +0800
Newsgroups gmane.comp.parsers.spirit.general
Message-ID <[email protected]>
On 11/19/21 8:57 pm, Phil Endecott via Spirit-general wrote:
> Hi Joel,
> 
> Joel de Guzman wrote:
>> Have a look at some of the examples. They work on UTF8.
> 
> /usr/local/src/boost_1_75_0/libs/spirit$ grep -ri unicode example/ classic/example repository/example
> example/support/utree/utf8_parser.hpp:#include <boost/regex/pending/unicode_iterator.hpp>
> 
> So none of the examples use BOOST_SPIRIT_UNICODE nor the
> unicode namespace. I also find no instance of \u.
> 
> Should I understand that these are not the right way to
> do UTF-8?

It just so happens that the examples do not require the char unicode classes and all
that stuff. Use it only if you need it. You can work on straight 8 bits with UTF8.
I suggest studying the examples that use John's UTF8 iterators. What happens is that
the iterators convert UTF8 to 32-bit unicode codepoints. You can inspect the value
of the codepoint directly, or if you need more power, use the spirit unicode facilities.

Cheers,
-- 
Joel