Boost logo

Boost Users :

From: Antonio Scotti (ascotti_at_[hidden])
Date: 2006-05-17 12:02:49


Thanks a lot. It worked wonderfully!

"John Maddock" <john_at_[hidden]> wrote in message
news:008b01c67995$99750970$3b160952_at_fuji...
> Antonio Scotti wrote:
>> Hi,
>> I have a portability problem with regex (probably due to localization
>> issues).
>>
>> I've found that, under Win32, the regular expression "\w" matches all
>> the alphanumeric chars, including non ascii ones (such as e grave or
>> e acute). This doesn't hold while under linux. In fact, \w only seems
>> to match ascii characters. I've tried chancing the locale, but
>> nothing changed.
>> Is there a way to make \w have on linux the same behaviour it has on
>> win32?
>
> Sure, it all comes down to what the default C++ locale is:
>
> std::locale::global(std::locale("en_US"));
>
> called before any regexes are constructed would set the locale to "en_US"
> *provided that locale is supported by your implementation*.
>
> Alternatively, you can set the locale in specific regex instances:
>
> boost::regex e;
> e.imbue(std::locale("en_US"));
> e.assign(my_regular_expression); // now uses en_US as it's locale
>
> 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