www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - setlocale not working as expected

reply "Frank De prins" <fdp mcs.be> writes:
Hello,

When I use setlocale with LC_ALL it does not seem to work.
I use nlb_belgium and, when I print (writeln in console) a 
floating point number, I expect the decimal separator to be a 
comma.  But it remains a dot.
When I use 0 instead of LC_ALL, it does work.
So I inspected the values defined for those locale cateory 
constants and they seem to be completely different from what I 
find in the Visual C++ headers.  Is this possible?  I mean, are 
they not expected to be the same, or is this vendor specific?

PS: This is how they are defined in VC:

#define LC_ALL          0
#define LC_COLLATE      1
#define LC_CTYPE        2
#define LC_MONETARY     3
#define LC_NUMERIC      4
#define LC_TIME         5

Also, in VC++, the return value of setlocale is defined as char* 
whereas, in D, it is int.  This makes it impossible to inspect 
the current locale.

Best regards and thanks for a wondderfull language,

Frank De prins
Feb 23 2012
parent reply "Jonathan M Davis" <jmdavisProg gmx.com> writes:
On Friday, February 24, 2012 08:10:31 Frank De prins wrote:
 Hello,
 
 When I use setlocale with LC_ALL it does not seem to work.
 I use nlb_belgium and, when I print (writeln in console) a
 floating point number, I expect the decimal separator to be a
 comma. But it remains a dot.
 When I use 0 instead of LC_ALL, it does work.
 So I inspected the values defined for those locale cateory
 constants and they seem to be completely different from what I
 find in the Visual C++ headers. Is this possible? I mean, are
 they not expected to be the same, or is this vendor specific?
 
 PS: This is how they are defined in VC:
 
 #define LC_ALL 0
 #define LC_COLLATE 1
 #define LC_CTYPE 2
 #define LC_MONETARY 3
 #define LC_NUMERIC 4
 #define LC_TIME 5
 
 Also, in VC++, the return value of setlocale is defined as char*
 whereas, in D, it is int. This makes it impossible to inspect
 the current locale.
 
 Best regards and thanks for a wondderfull language,
This list is not intended to be posted to directly by anyone but bugzilla itself. If you have a bug, please report it at d.puremagic.com/issues (in which case, that would be messaged to this list). If you have a question about learning D, then post to digitalmars-d-learn, and if you have a general D question then, post it to digitalmars-d. - Jonathan M Davis
Feb 24 2012
parent "John Chapman" <johnch_atms hotmail.com> writes:
On Friday, 24 February 2012 at 18:47:34 UTC, Jonathan M Davis 
wrote:
 On Friday, February 24, 2012 08:10:31 Frank De prins wrote:
 Hello,
 
 When I use setlocale with LC_ALL it does not seem to work.
 I use nlb_belgium and, when I print (writeln in console) a
 floating point number, I expect the decimal separator to be a
 comma. But it remains a dot.
 When I use 0 instead of LC_ALL, it does work.
 So I inspected the values defined for those locale cateory
 constants and they seem to be completely different from what I
 find in the Visual C++ headers. Is this possible? I mean, are
 they not expected to be the same, or is this vendor specific?
 
 PS: This is how they are defined in VC:
 
 #define LC_ALL 0
 #define LC_COLLATE 1
 #define LC_CTYPE 2
 #define LC_MONETARY 3
 #define LC_NUMERIC 4
 #define LC_TIME 5
 
 Also, in VC++, the return value of setlocale is defined as 
 char*
 whereas, in D, it is int. This makes it impossible to inspect
 the current locale.
 
 Best regards and thanks for a wondderfull language,
This list is not intended to be posted to directly by anyone but bugzilla itself. If you have a bug, please report it at d.puremagic.com/issues (in which case, that would be messaged to this list). If you have a question about learning D, then post to digitalmars-d-learn, and if you have a general D question then, post it to digitalmars-d. - Jonathan M Davis
Already reported as issue 5589 some time ago. http://d.puremagic.com/issues/show_bug.cgi?id=5589
Feb 25 2012