|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Cultural issues driving me INSANE!An application I started working on, used entirely by english-speaking users so I have no interest in supporting multiple languages. However the application does not always run on an english version if windows. Some of these users are located in various countries in europe and so their culture settings are different and its causing me a major headache!!!! Particular what is causing me extreme headaches is converting strings to float, and vice versa. All the data files in XML are in english format so the floats are represented as 1,234.56 which was at first causing float.Parse to horribly crash. So after adding CultureInfo.Invariant to every single call to float.Parse that went away. Now though I am dealing with the next problem that they can correctly open the data files, but when they are being saved again it is saving them with their local cultural settings so the 1,234.56 becomes 1.234,56 which means now when the file is being reopened the number because 123456 as the , is just being dropped!! Needless to say, this is corrupting the data and causing all sorts of issues... I really do not want to add a CultureInfo.Invariant to every number / text conversion in the entire program. I mean I will if I have to...but seriously.... Is there any way for me to tell the framework at the beginning one single time to use Invariant culture settings without me having to specify it for every single Convert, Parse, ToString call? Thanks in advance, -- Stephan 2003 Yamaha R6 The following should do the trick:
System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; Bruno "Stephan Rose" <kermos@somrek.diespammer.net> a écrit dans le message de news: karf321lfmu9i726ltrrlbocv4duger***@4ax.com...Show quote >I am really going nuts here. > > An application I started working on, used entirely by english-speaking > users so I have no interest in supporting multiple languages. However > the application does not always run on an english version if windows. > Some of these users are located in various countries in europe and so > their culture settings are different and its causing me a major > headache!!!! > > Particular what is causing me extreme headaches is converting strings > to float, and vice versa. All the data files in XML are in english > format so the floats are represented as 1,234.56 which was at first > causing float.Parse to horribly crash. So after adding > CultureInfo.Invariant to every single call to float.Parse that went > away. > > Now though I am dealing with the next problem that they can correctly > open the data files, but when they are being saved again it is saving > them with their local cultural settings so the 1,234.56 becomes > 1.234,56 which means now when the file is being reopened the number > because 123456 as the , is just being dropped!! Needless to say, this > is corrupting the data and causing all sorts of issues... > > I really do not want to add a CultureInfo.Invariant to every number / > text conversion in the entire program. I mean I will if I have > to...but seriously.... > > Is there any way for me to tell the framework at the beginning one > single time to use Invariant culture settings without me having to > specify it for every single Convert, Parse, ToString call? > > Thanks in advance, > > -- > Stephan > 2003 Yamaha R6 On Sat, 8 Apr 2006 19:41:43 +0200, "Bruno Jouhier"
<bjouh***@club-internet.fr> wrote: >The following should do the trick: Yup that seems to have done it.> >System.Threading.Thread.CurrentThread.CurrentCulture = >CultureInfo.InvariantCulture; >System.Threading.Thread.CurrentThread.CurrentUICulture = >CultureInfo.InvariantCulture; Thank you! -- Stephan 2003 Yamaha R6 > An application I started working on, used entirely by english-speaking This is not going to gain you too many customers in Europe.> users so I have no interest in supporting multiple languages. .... > Is there any way for me to tell the framework at the beginning one > single time to use Invariant culture settings without me having to > specify it for every single Convert, Parse, ToString call? Respecting user's cultural preferences is the basic rule of a "polite" application, even without translation. -- Mihai Nita [Microsoft MVP, Windows - SDK] http://www.mihai-nita.net ------------------------------------------ Replace _year_ with _ to get the real email On Sun, 09 Apr 2006 03:10:21 -0700, "Mihai N."
<nmihai_year_2***@yahoo.com> wrote: >> An application I started working on, used entirely by english-speaking Well this is not a commercial application and in that essence, not an>> users so I have no interest in supporting multiple languages. >... >> Is there any way for me to tell the framework at the beginning one >> single time to use Invariant culture settings without me having to >> specify it for every single Convert, Parse, ToString call? > >This is not going to gain you too many customers in Europe. >Respecting user's cultural preferences is the basic rule of a "polite" >application, even without translation. issue =) If this was a commercial application, I would be worried about it. But when I am writing a tool that I and fellow members of a game we all play write to make our lives easier, in my personal spare time, my priorities shift a little bit =) -- Stephan 2003 Yamaha R6
Show quote
"Stephan Rose" <kermos@somrek.diespammer.net> wrote in message <snip>news:karf321lfmu9i726ltrrlbocv4dugerfm6@4ax.com... >I am really going nuts here. > > An application I started working on, used entirely by english-speaking > users so I have no interest in supporting multiple languages. However > the application does not always run on an english version if windows. > Some of these users are located in various countries in europe and so > their culture settings are different and its causing me a major > headache!!!! > > Particular what is causing me extreme headaches is converting strings > to float, and vice versa. All the data files in XML are in english > format so the floats are represented as 1,234.56 which was at first > causing float.Parse to horribly crash. So after adding > CultureInfo.Invariant to every single call to float.Parse that went > away. I infer from the above that you are using either DTD's or nothing to define your XML implementation. I suggest that if possible you redefine your XML to use a W3C Schema - this would give you a strongly typed, culture independent format and what's more the .NET framework will read and write it for you from strongly typed classes generated by Studio or the xsd tool without any of the tedious, error prone and culture specific float.Parse stuff. Of course, in practice, you are probably tied into an unchangeable XML "definition" created by someone who thought XML was just about putting angle brackets around whatever a user types - in which case you have my sympathy. On Sun, 09 Apr 2006 14:22:38 GMT, "Nick Hounsome"
<nh***@nickhounsome.me.uk> wrote: Show quote > Actually that someone would be ME!!! =) First time really playing with>"Stephan Rose" <kermos@somrek.diespammer.net> wrote in message >news:karf321lfmu9i726ltrrlbocv4dugerfm6@4ax.com... >>I am really going nuts here. >> >> An application I started working on, used entirely by english-speaking >> users so I have no interest in supporting multiple languages. However >> the application does not always run on an english version if windows. >> Some of these users are located in various countries in europe and so >> their culture settings are different and its causing me a major >> headache!!!! >> >> Particular what is causing me extreme headaches is converting strings >> to float, and vice versa. All the data files in XML are in english >> format so the floats are represented as 1,234.56 which was at first >> causing float.Parse to horribly crash. So after adding >> CultureInfo.Invariant to every single call to float.Parse that went >> away. > ><snip> > >I infer from the above that you are using either DTD's or nothing to define >your XML implementation. > >I suggest that if possible you redefine your XML to use a W3C Schema - this >would give you a strongly typed, culture independent format and what's more >the .NET framework will read and write it for you from strongly typed >classes generated by Studio or the xsd tool without any of the tedious, >error prone and culture specific float.Parse stuff. > >Of course, in practice, you are probably tied into an unchangeable XML >"definition" created by someone who thought XML was just about putting angle >brackets around whatever a user types - in which case you have my sympathy. > > XML...thank you, I will look into that. -- Stephan 2003 Yamaha R6 > Actually that someone would be ME!!! =) First time really playing with Here are some guidelines on how to store/transfer data in a culture-> XML...thank you, I will look into that. independent way: http://www.mihai-nita.net/20051025a.shtml -- Mihai Nita [Microsoft MVP, Windows - SDK] http://www.mihai-nita.net ------------------------------------------ Replace _year_ with _ to get the real email |
|||||||||||||||||||||||