Boost logo

Boost :

From: Rogier van Dalen (rogiervd_at_[hidden])
Date: 2004-10-22 15:37:32


On Fri, 22 Oct 2004 18:09:12 +0300, Peter Dimov <pdimov_at_[hidden]> wrote:
> Eric Niebler wrote:
> >
> > utf8_string str;
> > str.reserve(some_big_number);
> >
> > ifstream file("utf8.txt");
> > istreambuf_iterator<char8_t> begin(file), end;
> >
> > std::copy( begin, end, back_inserter(str) );
> >
> >
> > This can't throw if you want people to use your string class.
>
> utf8_string str( begin, end );

Seems sensible, though I would like to reintroduce the as_utf8_tag
class I introduced earlier. I think the utf8_string we're talking
about is either a sequence of char32_t's, or a sequence of
unicode::character's (encoded differently underlyingly).
Whatever it is, I think you'll want to make a difference between a
UTF-8 code unit iterator, a UTF-16 code unit iterator and a UTF-32
one, and make it:

utf8_string str (begin, end, as_utf8_tag());

Rogier


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