|
Boost : |
From: Stefan Seefeld (seefeld_at_[hidden])
Date: 2004-08-22 22:57:56
Rainer Deyke wrote:
> Stefan Seefeld wrote:
>
>>Isn't it abusive to force utf-8 into a std::string ? While it is
>>technically possible the semantics isn't quite the same. operator
>>[] (size_t i) wouldn't return the i'th character any more, at
>>least not for characters outside the ascii range.
>
>
> I don't think so. In C and C++, the type 'char' represents not only a text
> character, but also a byte of binary data. For example, when using the
> iostream library to read binary files, the data will be read as a sequence
> of 'char's. 'std::string' is the most useful container for blocks of binary
> data, largely because of the stringstream classes.
I don't agree: When I want to read binary data, i.e. a sequence of 'char's,
I don't use std::istream to begin with, as iostreams are all about formatting.
Instead I would look at std::streambuf, as that's what encapsulates the device
to read from.
So, I don't see at all why I would read in binary data from a std::stringstream
into a std::string.
Regards,
Stefan
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk