Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I (an American) test whether my ASP.NET/SQL Server app is handling decimals correctly for Germany

In the US, you use a "." as the separator, but in Germany you use a ",". I'm trying to test whether my logic is smart enough to handle either one but I seem to be failing to put my Windows 2000 machine into German mode.

I went to Control Panel, Regional Options, and changed "Your locale" to "Germany". I then restarted both IIS and SQL Server. But my changes don't seem to have taken effect.

These lines still show "." to be the separator.

System.Globalization.CultureInfo ci = new System.Globalization.CultureInfo( System.Threading.Thread.CurrentThread.CurrentCulture.Name);

Response.Write(ci.NumberFormat.NumberDecimalSeparator);

What am I doing wrong?

like image 746
Corey Trager Avatar asked Apr 04 '09 17:04

Corey Trager


2 Answers

The best way to test this is to add a globalization element to your web.config, e.g.:

<system.web>
   <globalization culture="de-DE" uiCulture="en-US" />
</system.web>

Changing culture to de-DE will affect date and numeric formats: you could also change uiCulture if you want, leaving uiCulture as en-US means you will get exception messages in US English.

like image 148
Joe Avatar answered Oct 06 '22 01:10

Joe


When you set your Regional Settings, did you make sure to "Apply all settings to the current user account and to the default user profile" (Advanced tab) ?

That should do it in most cases. I'm also assuming that your culture is not preset to "en-us" in the globalization element of Web.config.

It appears that you don't want to do it by setting your Culture settings manually in code, rather you want them inherited by System settings. That, IMO, is a good way of checking since your changes should be propagated to SQL server as well.

like image 43
Cerebrus Avatar answered Oct 06 '22 00:10

Cerebrus