
23 Aug
2004
23 Aug
'04
3:27 a.m.
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. Utf-8 is just a special case of binary data. -- Rainer Deyke - rainerd@eldwood.com - http://eldwood.com