472,146 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,146 software developers and data experts.

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

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
1 2247
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.

Similar topics

10 posts views Thread by Angus Leeming | last post: by
10 posts views Thread by Minti | last post: by
4 posts views Thread by songkv | last post: by
11 posts views Thread by Dennis Allison | last post: by
87 posts views Thread by Robert Seacord | last post: by
5 posts views Thread by shaanxxx | last post: by
41 posts views Thread by Dead Loop | last post: by
28 posts views Thread by v4vijayakumar | last post: by
5 posts views Thread by polas | last post: by
9 posts views Thread by sarajan82 | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.