Watch, Follow, &
Connect with Us

Please visit our new home
community.embarcadero.com.


Welcome, Guest
Guest Settings
Help

Thread: imbue broken() in 10.2 Update 3?



Permlink Replies: 1 - Last Post: Apr 16, 2018 9:14 AM Last Post By: Remy Lebeau (Te... Threads: [ Previous | Next ]
Sean Hoffman

Posts: 126
Registered: 3/28/99
imbue broken() in 10.2 Update 3?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 15, 2018 10:59 AM
#pragma hdrstop
#pragma argsused
 
#ifdef _WIN32
#include <tchar.h>
#else
  typedef char _TCHAR;
  #define _tmain main
#endif
 
#include <iostream>
#include <sstream>
#include <locale>
 
int _tmain(int argc, _TCHAR* argv[]) 
{
	std::wstringstream	ss;
 
	ss.imbue(std::locale(""));
 
	ss << 123938133;
 
	std::wcout << ss.str() << std::endl;
 
	ss.imbue(std::locale("en_US.UTF-8"));
 
	std::wcout << 93839311039 << std::endl;
   
	return 0;
}


Outputs:
123938133
93839311039

Should pick up the thousands separator from the environment. Wasted an hour with this one (works fine in VS, haven't tried Clang or g++ yet). Does this work for anyone else?

Thanks
Remy Lebeau (Te...


Posts: 9,442
Registered: 12/23/01
Re: imbue broken() in 10.2 Update 3?
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 16, 2018 9:14 AM   in response to: Sean Hoffman in response to: Sean Hoffman
Sean Hoffman wrote:

ss.imbue(std::locale(""));
ss.imbue(std::locale("en_US.UTF-8"));

Should pick up the thousands separator from the environment.

More likely, the locales you are imbue'ing are not defining a thousands
separator to begin with, rather than being a problem with imbue()
itself. The behavior of std::locale("") is highly varied from one
machine to another. And I doubt the default UTF-8 locale defines a
thousands separator on every machine, either.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02