
John Christopher wrote:
Hi,
std::string a; std::wstring b( a.begin(),a.end()); std::string c(b.begin(),b.end());
for a while now, I have started wondering if I was not shooting myself in
The reason I asked is that while I have been using the foot without knowing... I am no Unicode expert and Boost facilities in that area would certainly give me some confidence. Boost is nice also because codes are visited by skilled and experienced programmers and I am glad to benefit from that... :) More generally, I am still struggling on which string class I should use: std::string, std::wstring, some custom class...
Not claiming to be a expert in this field, I typedef std::wstring string; for my project if I need Unicode. I expect the iterators of some Unicode string class to (at least) give me wide characters, regardless of the underlying in-memory encoding. The 'typedef' (placed in some global header) allows me to easily change the string class, if I have to (e.g. for saving memory or bandwidth). std::string is basically just a container for bytes, that is length() will start lying as soon as there are characters that are represented by more than one byte (like with UTF-8). Regards, Tobias