By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,428 Members | 1,851 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,428 IT Pros & Developers. It's quick & easy.

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

P: n/a
Hello all!
std::ostringstream 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

Nov 22 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I got reply from other group:

"Ulrich Eckhardt" <ec******@satorlaser.com> wrote in message
news:<uf************@satorlaser.homedns.org>...
Voronkov Konstantin wrote:
std::ostringstream 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.


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::ostringstream stream;
stream.imbue( std::locale::classic());
The same code in little sample I made result in "8080" string value. I
want to ask where the digit delimeter came from?


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.
And how can I disable it?


Firstly, you shouldn't. Secondly, you can reset the global locale to the
default C locale with
std::locale::global( std::locale::classic());
I'm using default STL shipped with VS 6.0 sp5.


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


Nov 22 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.