Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2006-03-21 05:36:06


> Now I tried to integrate wregex in the software, but it just would
> not compile complaining about missing wstring (and defined
> BOOST_NO_WREGEX). I tried to make up my own regex character traits
> class, but this does not seem to help, because some other
> classes/types (such as sub_match) make use of basic_string<charT>.
>
> Is there any way to bypass the problem?

OK all the following comments apply to 1.33.1.

There are two easy options and one harder option:

Easy option #1, use STLport if it supports wstring.
Easy option #2, use the ICU/Unicode support in 1.33.1 to search your data
directly (as long as it's in UTF-8, UTF-16 or UTF-32 format). You'll get
back iterators into your data (whatever encoding it's in), so there's no
problems determining offsets etc.

The slightly harder option, as you've guessed already: write your own traits
class, from 1.33 onwards you can use vector<charT> in place of
basic_string<charT> in the traits class. If you take a look at the traits
class used by the Unicode/ICU support code it should give you the general
idea, and there are docs here:
http://www.boost.org/libs/regex/doc/concepts.html#traits

And finally... if you data is in MBCS format you might get some ideas from
the unicode suuport code in 1.33.x: basically in order to handle multibyte
encodings it converts from UTF-8 or UTF-16 to UTF-32 code points on the fly.
Of course this requires that the on-the-fly conversions are bidirectional,
this works OK for Unicode, but I'm not sure about how far you would get with
other encodings.

HTH, John.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net