Encoding
OvermindDL1 <[email protected]> Fri, 11 Dec 2009 18:47:14 -0700
| Newsgroups | gmane.comp.parsers.spirit.devel |
|---|---|
| Message-ID | <[email protected]> |
You know how I suggested something like this for character encoding? parse<standard_wide>(...); parse<utf8>(...); parse<ascii>(...); etc... Re-thinking it, what about just treating it like space, rule definition could be like: rule<Iterator,int(),encoding,space> // the int(), encoding, and space parts being in any order of course, the encoding can be figured out by a tag For a plain parse function like this: parse(beg,end, *char_, output); We could specify the encoding (if not using the default of utf8 when we finally get it) in two easy ways that I see, either: parse<ascii>(beg,end, *char_, output); Or: parse_enc(beg,end, *char_, output, ascii); // where ascii is some static instanced empty tag just used to determine what encoding to use if not standard or: parse_enc(beg,end, *char_, output, options<ascii>()); For the second, could perhaps refine the ordering so we could use the standard parse and parse_phrase so we do not need to increase each exponentially. The third could be interesting as it would let us add more options in the future without worrying about ordering passing in things or about function name blow-up. Regardless, there are times where I have changed encoding in some grammars, so just like how you can change the skip parser with skip, we should have one that can change encoding as well... It would require some back-end changes no doubt, but if a sensible default is used (we really need utf8 support) then it would require minimal changes to the person using Spirit, mostly just not bringing in an encoding namespace and instead bringing in char_ and its kin from the normal boost::spirit namespace like the other Qi/Karma things like int_ and so forth. Any thoughts? This is just a random discussion for now... ------------------------------------------------------------------------------ Return on Information: Google Enterprise Search pays you back Get the facts. http://p.sf.net/sfu/google-dev2dev