Boost logo

Boost :

Subject: Re: [boost] [general] What will string handling in C++ looklike inthe future [was Always treat ... ]
From: Stewart, Robert (Robert.Stewart_at_[hidden])
Date: 2011-01-19 15:42:03

Dave Abrahams wrote:
> Peter Dimov wrote:
> > Dave Abrahams wrote:
> > > Nonono; if you don't want to choose an encoding, you store it as a
> > > raw_string, (a.k.a. std::string, for example)!
> >
> > OK. You're designing a portable library that talks to the OS. It has
> > the following functions:
> >
> > T get_path( ... );
> > void process_path( T );
> >
> > What do you use for T? string or utf8_string?
> OK, according to all the experts (like you), we should be trafficking
> in UTF-8 everywhere, so I guess I'd say T is utf8_string (well, T is
> boost::filesystem::path, but that begs the same questions,
> ultimately).

I think it depends upon get_path() and process_path(). If get_path() returns an OS byte sequence and process_path() uses its argument for OS calls, then T is std::string as both functions are encoding agnostic. If process_path() is to do character-based processing, then it probably needs a UTF8 string and so it might expect a utf8_string which, presumably, would have a converting constructor from std::string assumed to have unknown encoding. (I have no idea whether it is possible to determine the encoding from the byte sequence, but I suppose it is.)

In a system which assumes UTF8 encoding in std::strings, then utf8_string might be a typedef for std::string and the only concern is that all sources of such strings be UTF8.

Rob Stewart robert.stewart_at_[hidden]
Software Engineer, Core Software using std::disclaimer;
Susquehanna International Group, LLP

IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

Boost list run by bdawes at, gregod at, cpdaniel at, john at