Why std::ostringstream inserts number group delimeter and how to disable this mode?

  • Thread starter Voronkov Konstantin
  • Start date
V

Voronkov Konstantin

Hello all!


std::eek:stringstream stream;
stream << 8080;
std::string str = stream.str(); // str == "8 080"


The code shown above in mine big program result the str variable value
to
contain thouzand digits space delimeter.
The same code in little sample I made result in "8080" string value. I
want
to ask where the digit delimeter came from?
And how can I disable it?

I'm using default STL shipped with VS 6.0 sp5.

Thanks in advance,
Voronkov Konstantin
 
V

Voronkov Konstantin

I got reply from other group:

Ulrich Eckhardt said:
This and several other such things depend on the locale. In order to get
locale-independent formatting, you should imbue() with the C locale:

std::eek:stringstream stream;
stream.imbue( std::locale::classic());


Someone set the locale from the default C locale to something else, probably
the one defined by the environment - this at least is the intended way it
should be done.


Firstly, you shouldn't. Secondly, you can reset the global locale to the
default C locale with
std::locale::global( std::locale::classic());


You don't mean STL but C++ standardlibrary. The STL never had anything but
containers, iterators and algorithms, so even the relaked interpretation of
that word is wrong here.

Uli
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top