
Miro Jurisic <macdev@meeroh.org> writes:
In article <uoeiuu4n6.fsf@boost-consulting.com>, David Abrahams <dave@boost-consulting.com> 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.
Okay. -- Dave Abrahams Boost Consulting http://www.boost-consulting.com