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

C# vs. J# String behavior with non-US regional settings

P: n/a
Hi,

The following behavior when using J# vs. C# is really bothering me.
When I have the regional settings on my workstation set to a non-US
settings [to test software behavior for international users](eg:
Danish); it seems that J# disregards the regional settings. Where-as
C# automatically picks up the regional settings and applies them.

For example, the following J# code:
public static void main(String[] args)
{
double d = 29.97;
String str = "Here is a floating point number:: " + d + "\n";
System.Console.WriteLine (str);
}

will always output: Here is a floating point number:: 29.97
regardless of what the regional settings are specified as.

The following C# code:
static void Main(string[] args)
{
double d = 29.97;
string str = "Here is a floating point number: " + d + "\n";
Console.WriteLine (str);
}

will output: Here is a floating point number:: 29.97
when the regional settings are set to English-US
but will correctly output:
Here is a floating point number:: 29,97
when the regional settings are set to Danish (with a locale of the
Netherlands)

I run into big problems if a J# assembly is feeding input to a C#
assembly. The C# assembly automatically adjusts to the regional
settings and will reject the J# values if they differ from what a
valid value in the region would be.

Using the example above, the J# output of 29.97 when processed by a C#
assembly (with the regional settings of Danish); will throw an invalid
format exception if you attempt to change the string back into a
double.

Is there any easy way to have the J# routines adhere to the specified
regional settings?

Thanks for any help.

-john
Nov 16 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Is there any easy way to have the J# routines adhere to the specified
regional settings?


If you explicitly call d.ToString() you have full control over the
formatting.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Nov 16 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.