Boost logo

Boost :

Subject: Re: [boost] Formal Review Request: Boost.String.Convert
From: Hartmut Kaiser (hartmut.kaiser_at_[hidden])
Date: 2009-02-17 08:34:42


> > Why not allow to convert between different string types?
>
> Yes, I believe that is a very sensible question. In fact, I've
> tightened up
> the type checks for the implemented boost::string::convert() to
> minimize
> possible signature clashes with/of further extensions (via
> specializations/oveloads).
>
> In the current form boost::string::convert() is essentially a
> replacement
> for lexical_cast with added forrmatting, locale, etc. support. To add,
> say,
> u8string<->wstring conversion support we'll need overloads
>
> std::wstring convert(std::u8string)
> std::u8string convert(std::wstring)
>
> added.

Makes sense.

> > Possible applications:
> >
> > - std::string <--> std::wstring or similar (based on a future
> > Boost.Unicode library)
>
> I am not sure we can do std::string <-> std::wstring unless we know
> what
> std::string represents (currently it can be UTF8 or MBCS). If, with the
> introduction of std::u8string, std::string is guaranteed to be MBCS,
> then I
> guess we can have std::string <-> std::wstring as well.

That's what I meant. Sorry for being in-concise.

> > - conversion between different symbol (character) sets
>
> Currently convert() heavily relies on supplied types. Are we going to
> have
> distinct types for different symbol (character) sets? If not, then we
> might
> move forward as I've done for the throwing behavior (i.e. run-time
> configuration vs. compile-time configuration):
>
> int i = boost::string::convert(str, -1) >> boost::throw_t();
>
> to pass a clue/directive what to do. Similarly we might do
>
> string new_set_str = boost::string::convert(old_set_str) >>
> new_set_directive();
>
> Just thinking out loud. Does it look anywhere close to what you had in
> mind?

In Spirit we use a

    using namespace boost::spirit::ascii;

(or similar) to tie in a specific character set. I'm not sure if this is a
viable solution for you.

Regards Hartmut


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk