Boost logo

Boost Users :

From: Ben Hutchings (ben.hutchings_at_[hidden])
Date: 2005-11-15 06:53:56


Sean Rohead wrote:

>std::string narrow(std::wstring source)
>{
> std::string result(source.size(), char(0));
> typedef std::ctype<wchar_t> ctype_t;
> const ctype_t& ct = std::use_facet<ctype_t>(std::locale());
> ct.narrow(source.data(), source.data() + source.size(), '\u00B6',
>&(*result.begin()));
> return result;
>}
>
>
Not that this is likely to have anything to do with the error, but you
mustn't use string::begin() like that. The sequence of characters is not
guaranteed to be an array. If you want that guarantee, use a vector instead.

Ben.


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