473,574 Members | 5,869 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.WriteLi ne (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 2370
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
8157
by: Angus Leeming | last post by:
Hello, Could someone explain to me why the Standard conveners chose to typedef std::string rather than derive it from std::basic_string<char, ...>? The result of course is that it is effectively impossible to forward declare std::string. (Yes I am aware that some libraries have a string_fwd.h header, but this is not portable.) That...
10
1466
by: Minti | last post by:
I tried the following code on Borland C++ complier and Microsoft VC7.0 both seem to give conflicting results void foo(const int& x) { std::cout << "In const foo\n"; } void foo(int& x) {std::cout << "In non-const foo\n"; } int main(void) { foo(5);
4
5381
by: songkv | last post by:
Hi, I am trying to reassign an array of char to a string literal by calling a function. In the function I use pointer-to-pointer since I want to reassign the "string array pointer" to the string literal. But the second printf seems to give me garbage. Any advise on what I am doing wrong? Thanx
11
2089
by: Dennis Allison | last post by:
Which C libraries (current and historical) interpret a null pointer as a pointer to a null (that is, empty) string?
87
5076
by: Robert Seacord | last post by:
The SEI has published CMU/SEI-2006-TR-006 "Specifications for Managed Strings" and released a "proof-of-concept" implementation of the managed string library. The specification, source code for the library, and other resources related to managed strings are available for download from the CERT web site at: ...
5
1529
by: shaanxxx | last post by:
void foo(char * str) { str = str; } int main() { const char str = "Hello"; foo(str); // i get warning here
41
2339
by: Dead Loop | last post by:
Hi all, I'm a beginner and my question is: Are there any differences between char *p = "Hello, world!"; and const char *p = "Hello, world!"; ?
28
2516
by: v4vijayakumar | last post by:
#include <string> #include <iostream> using namespace std; int main() { string str; str.resize(5); str = 't';
5
2887
by: polas | last post by:
Good morning, I have a quick question to clear up some confusion in my mind. I understand that using a string literal in a declaration such as char *p = "string literal" declares a pointer to memory holding the string and the string might very well be held in read only memory. However, I am sure that I read somewhere that the declaration...
9
1490
by: sarajan82 | last post by:
Hi All, I have a string represented by char* (I do not user string class): char *s="abcd"; Assume I want to remove the last two elements of s. What is the standard solution for this? Can I just change the value of s to '\0'? Thanks a lot
0
7741
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8085
Oralloy
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8259
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7838
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8126
tracyyun
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5637
isladogs
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5328
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3781
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1362
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.