Is there a way using standard C++ to obtain the machine locale? I need
to parse a date written in a text file, so i have to know first what is
the locale to be able to store correctly the date in a structure.
Thanks. 9 2270
scuro wrote: Is there a way using standard C++ to obtain the machine locale? I need to parse a date written in a text file, so i have to know first what is the locale to be able to store correctly the date in a structure.
Why do you need to know the current locale? It's used by default in C++.
"Rolf Magnus" writes: scuro wrote:
Is there a way using standard C++ to obtain the machine locale? I need to parse a date written in a text file, so i have to know first what is the locale to be able to store correctly the date in a structure.
Why do you need to know the current locale? It's used by default in C++.
Perhaps he has devised some fiendishly clever way to transport programs or
data from one location to another?
osmium wrote: "Rolf Magnus" writes:
scuro wrote:
Is there a way using standard C++ to obtain the machine locale? I need to parse a date written in a text file, so i have to know first what is the locale to be able to store correctly the date in a structure.
Why do you need to know the current locale? It's used by default in C++.
Perhaps he has devised some fiendishly clever way to transport programs or data from one location to another?
Then he wouldn't need the current system locale, but the one that the data
was encoded in.
Rolf Magnus a écrit : Why do you need to know the current locale? It's used by default in C++.
Really?
I don't know what the standard says about this but, on the platform I'm
most familiar with (VC++ 7.1), the global locale is initially set to
the "classic" locale: http://msdn2.microsoft.com/en-us/library/9dzxxx2c.aspx
To get the user's locale, one has to use std::locale("");
Éric
Rolf Magnus wrote: Why do you need to know the current locale? It's used by default in C++.
Suppose you have a string like this one: "The party will be on 1/2/2000"
(this string was written into a file by a program on the same machine
where I run my program).
Now, the question is: if I want to go to the party I must go on 1
February 2000 or on 2 January 2000?
I have tho know the machine locale to correctly parse the date.
scuro <cr****@levami.lycos.com> wrote: Suppose you have a string like this one: "The party will be on 1/2/2000" (this string was written into a file by a program on the same machine where I run my program).
Now, the question is: if I want to go to the party I must go on 1 February 2000 or on 2 January 2000?
This may not help you solve your locale problem, but in the future you
may want to consider using ISO 8601 date/time format, as it is
unambigous, plus you get the added bonus that a chronological sort and a
lexicographical sort are the same:
YYYY-MM-DD hh:mm:ss http://www.cl.cam.ac.uk/~mgk25/iso-time.html
--
Marcus Kwok
Replace 'invalid' with 'net' to reply
"Marcus Kwok" writes: Suppose you have a string like this one: "The party will be on 1/2/2000" (this string was written into a file by a program on the same machine where I run my program).
Now, the question is: if I want to go to the party I must go on 1 February 2000 or on 2 January 2000?
This may not help you solve your locale problem, but in the future you may want to consider using ISO 8601 date/time format, as it is unambigous, plus you get the added bonus that a chronological sort and a lexicographical sort are the same:
Just a wild guess, but what if someone *else* wrote the message? ISTM if
the OP wrote the message, he would have a pretty good clue as to what it
meant. I sometimes receive mail on stationary I don't like, what is the
protocol for handling that?
On Fri, 09 Jun 2006 11:00:29 +0200, I waved a wand and this message
magically appeared from Rolf Magnus: Is there a way using standard C++ to obtain the machine locale? I need to parse a date written in a text file, so i have to know first what is the locale to be able to store correctly the date in a structure.
Why do you need to know the current locale? It's used by default in C+ +.
What he's trying to say is he needs to know what format the date is in
for that locale the system is running on.
For that matter, there really needs to be a way programs can find out
what country it is being used in. Is there a way like that?
-- http://www.munted.org.uk
Take a nap, it saves lives.
In article <44********************@news.tiscali.it>,
scuro <cr****@levami.lycos.com> wrote: Is there a way using standard C++ to obtain the machine locale? I need to parse a date written in a text file, so i have to know first what is the locale to be able to store correctly the date in a structure.
Thanks.
#include <iostream>
using namespace std;
int main (int argc, char * const argv[]) {
locale native("");
cout<<native.name()<<endl;
return 0;
}
a typical answer is
"C"
which tells you that a classic US English ASCII locale is used. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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: 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: |
last post by:
Hi all,
running the following code as an console application:
#include <locale>
#include <iostream>
#include <sstream>
#include <tchar.h>
using namespace std;
|
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: cris |
last post by:
Hi,
I got trouble when I try to change the locale used in a program foo.cc
// ----------------- begin
#include <iostream>
#include <locale>
#include <exception>
using namespace std;
int...
|
by: Daniele C. |
last post by:
I will report a snippet from http://php.net/setlocale
I spent about 2 seconds before thinking: can it really be? I mean, is
there no way to set locale info per thread? And after a brief web...
|
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: Roman Bertle |
last post by:
Hello,
I try to format monetary values using the locale module, python2.5:
Python 2.5.2a0 (r251:54863, Jan 3 2008, 17:59:56)
on linux2
Type "help", "copyright", "credits" or "license" for...
|
by: Mario Ruggier |
last post by:
Hi,
i had the following problem when installing py3.0rc1 on a Mac OS X
10.5.5. On this system, the default locale values are:
$ locale
LANG=
LC_COLLATE="C"
LC_CTYPE="UTF-8"
LC_MESSAGES="C"
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
| |