On 21/02/2013 21:48, ?? Tiib wrote:
What is the "this"? It should work. Currently most people use std::string
(that actually contains UTF-8 encoded text) for storing texts. I fully
agree with you that it is loose and unsafe thing. However it is unlikely
that some revolution is coming. Billions of lines of code and millions of
interfaces all over the world use that std::string and problems are
consistently elsewhere.
std::string does not contain UTF-8 encoded text. It contains chars. If
your implementation treats those chars as UTF-8 encoded characters, then
fine - but that is NOT part of the standard, it's just something that
*nix operating systems tend to do.
You might like to consider what happens when you resize a string to
remove part of a multibyte character. There's nothing there to make it
UTF safe...
I suspect this is why fstream::open takes a char* - someone assumed that
a char* was utf-8, and for those operating systems where a filename is
unicode it's broken.
Actually, it's not. The historical reason is that fstream::open was
designed at a time when std::string did not yet exist.
Note that in C++11 we do have an fstream::open(std::string). And without
a required UTF-8 support.