Hi all,
running the following code as an console application:
#include <locale>
#include <iostream>
#include <sstream>
#include <tchar.h>
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
// ----------------------------------------
const char* arrLocaleNames[] = {
"German_germany",
"german-austrian",
"german-swiss",
"german-austrian",
"C",
"French",
"",
};
ostringstream* poStrStream = new ostringstream;
*poStrStream << "output of double a=1234.56E0 using different
locales:" << endl;
double a = 1234.56E0;
for (int i=0; i < sizeof(arrLocaleNames)/sizeof(arrLocaleNames[0]);
i++) {
poStrStream->imbue(locale( arrLocaleNames[i] ) );
*poStrStream << a << " <- locale(\"" << arrLocaleNames[i] << "\")
getloc().name():\"" <<
poStrStream- >getloc().name().c_str() << "\"" << endl;
}
// ----------------------------------------
cout << poStrStream->str();
delete poStrStream;
int k;
cin >k;
return 0;
}
leads to the correct output:
output of double a=1234.56E0 using different locales:
1.234,56 <- locale("German_germany")
getloc().name():"German_Germany.1252"
1.234,56 <- locale("german-austrian")
getloc().name():"German_Austria.1252"
1'234.56 <- locale("german-swiss")
getloc().name():"German_Switzerland.1252"
1.234,56 <- locale("german-austrian")
getloc().name():"German_Austria.1252"
1234.56 <- locale("C") getloc().name():"C"
1á234,56 <- locale("French") getloc().name():"French_France.1252"
1.234,56 <- locale("") getloc().name():"German_Germany.1252"
But compiling the code between the two comment lines in a WinForms-project
as it is created by the VC2005-IDE using the same header files and namespace
std statement as above, results in the following output:
output of double a=1234.56E0 using different locales:
1234.56 <- locale("German_germany") getloc().name():"German_Germany.1252"
1234.56 <- locale("german-austrian") getloc().name():"German_Austria.1252"
1234.56 <- locale("german-swiss")
getloc().name():"German_Switzerland.1252"
1234.56 <- locale("german-austrian") getloc().name():"German_Austria.1252"
1234.56 <- locale("C") getloc().name():"C"
1234.56 <- locale("French") getloc().name():"French_France.1252"
1234.56 <- locale("") getloc().name():"German_Germany.1252"
Obviously the locale function produces the same output as in the console
version but the stream output stays with the standard "C" settings!
What do I have to change (compiler settings, move the piece of code out of
the click-handler of the WinForm) to get the correct results?
Thanks for your help
Rainer 0 1158 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Jeff Epler |
last post by:
I'd expect these two to be identical, but they don't seem to be.
>>> import locale
>>> locale.setlocale(locale.LC_ALL, "fr_FR")
'fr_FR'
>>> locale.nl_langinfo(locale.DAY_1)
'dimanche'
>>> #...
|
by: Benoît Dejean |
last post by:
here are my locales
benoit@athlon >> locale
LANG=fr_FR.UTF-8
LC_CTYPE="fr_FR.UTF-8"
LC_NUMERIC="fr_FR.UTF-8"
LC_TIME="fr_FR.UTF-8"
LC_COLLATE="fr_FR.UTF-8"
LC_MONETARY="fr_FR.UTF-8"
|
by: Ksenia Marasanova |
last post by:
Hi,
I have some problems with locale module.
On my workstation, changing locale doesn't have effect:
Python 2.3 (#1, Sep 13 2003, 00:49:11)
on darwin
Type "help", "copyright", "credits" or...
|
by: Jorgen Grahn |
last post by:
I'm sitting here with a Debian Linux 'Woody' system with the default Python
2.2 installation, and I want the re module to understand that
re.compile(r'\W+'. re.LOCALE) doesn't match my national,...
|
by: Timothy Smith |
last post by:
hi there i need to set my locale so that when i output a number it's
formatted with thousands grouped. the problem i've found is there
doesn't seem to be very good cross platform support for...
|
by: Cagdas Ozgenc |
last post by:
Greetings.
I am confused about C++ standard library locale stuff. It seems as if the
implementations of locales are not part of the library, but only some
guideline classes are there.
What is...
|
by: Torsten Bronger |
last post by:
Hallöchen!
I have to generate excerpts in different human languages in a
program. In general, the language is not the locale's language, but
set at runtime. Nevertheless, GNU's gettext should...
|
by: David Thielen |
last post by:
Hi;
I have help html pages for each page of my ASP.NET webapp. So for the page
datasource.aspx, I have help\datasource.htm.
Bu what I want when the hyperlink is clicked, for it to look for the...
|
by: robert |
last post by:
Why can the default locale not be set by its true name? but only by '' ? :
PythonWin 2.5 (r25:51908, Sep 19 2006, 09:52:17) on win32.
(None, None)
Traceback (most recent call last):
File...
|
by: Donn Ingle |
last post by:
Hello,
I hope someone can illuminate this situation for me.
Here's the nutshell:
1. On start I call locale.setlocale(locale.LC_ALL,''), the getlocale.
2. If this returns "C" or anything...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |