473,756 Members | 2,900 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 2386
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
8179
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 said, is there any real reason why I can't derive an otherwise empty
10
1482
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
5395
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
2102
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
5149
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: http://www.cert.org/secure-coding/managedstring.html
5
1533
by: shaanxxx | last post by:
void foo(char * str) { str = str; } int main() { const char str = "Hello"; foo(str); // i get warning here
41
2381
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
2548
by: v4vijayakumar | last post by:
#include <string> #include <iostream> using namespace std; int main() { string str; str.resize(5); str = 't';
5
2898
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 char a = "string literal", even though a is an array (and I understand the differences between...
9
1495
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
9456
marktang
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9843
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5142
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.