Re: [pcre-dev] implementing support for std::wstring in pcre…

Pàgina inicial
Delete this message
Autor: Thorsten Schöning
Data:  
A: pcre-dev
Assumpte: Re: [pcre-dev] implementing support for std::wstring in pcrecpp
Guten Tag Craig Silverstein,
am Mittwoch, 5. Januar 2011 um 19:31 schrieben Sie:

> There's another way to do it, which is uglier but doesn't require
> modifying pcre: use a conversion operator.


> For this to work, you'll need to subclass std::wstring. The subclass
> will define the constructors you need, and also an 'operator
> StringPiece() const'. It's this method that will convert the wstring
> into a utf-8 string, wrap that in a stringpiece, and return it.


> Then you should be able to pass in your wstring-subclass whenever
> pcrecpp expects a StringPiece. Would this work for your needs?


Sounds like with this approach the caller should have to set the right
options for UTF-8-support on it's own and one has no influence on how
captured values are returned. Handling the conversion in the caller is
not a problem, that's what we are doing right now. I wanted are more
transparent way and that the caller must not care about those things,
hopefully resulting in less errors possible.

I wanted to have something possible like the following, where the
caller just inputs his Unicode and pcrecpp is able to return either
Unicode and UTF-8-Strings, whatever is needed by the caller.

pcrecpp::RE("...").Full_Match(std::wstring, &std::wstring, &std::string, &int, ...)

Mit freundlichen Grüßen,

Thorsten Schöning

--
Thorsten Schöning
AM-SoFT IT-Systeme - Hameln | Potsdam | Leipzig

Telefon: Potsdam: 0331-743881-0
E-Mail:  tschoening@???
Web:     http://www.am-soft.de


AM-SoFT GmbH IT-Systeme, Konsumhof 1-5, 14482 Potsdam
Amtsgericht Potsdam HRB 21278 P, Geschäftsführer: Andreas Muchow