From: Miro Jurisic (macdev_at_[hidden])
Date: 2004-10-22 12:03:15


In article <uoeiuu4n6.fsf_at_[hidden]>,
 David Abrahams <dave_at_[hidden]> wrote:

> Is this going to be illegal for most fs, then?
>
> std::copy(
> std::istream_iterator<char>(f), std::istream_iterator<char>(),
> std::back_inserter(my_utf8_string));
>
> I think it pretty much has to work.

I think this is a red herring. A UTF-8 string is not a sequence of chars, nor is
every char convertible to a UTF-8 char, so why should this work any more than

vector<void*> my_vector;

    std::copy(
         std::istream_iterator<char>(f), std::istream_iterator<char>(),
         std::back_inserter(my_vector));

?

OTOH, A UTF-8 string is a sequence of Unicode chars, so what should work is:

    std::copy(
         std::istream_iterator<unicode_char>(f),
std::istream_iterator<unicode_char>(),
         std::back_inserter(my_utf8_string));

with the semantics that every time you hit the iterator, an entire unicode
character is read off the stream and appended to the string.

meeroh