Boost logo

Boost Users :

From: Tobias Schwinger (tschwinger_at_[hidden])
Date: 2007-01-28 04:25:26


John Christopher wrote:
> Hi,
>
> The reason I asked is that while I have been using
>>> 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 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


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net