Flash Gordon <spam@flash-gordon.me.ukwrites:
Quote:
corley wrote:
Quote:
>Hello world,
>I am having a problem with the decimal symbol. The result of writing
>a
>floating-point-number
> to an xml document (using libxml2 from xmlsoft.org) is
> <number>10,1234</number>
>The result I want is a dot as decimal symbol, like this
><number>10.1234</number>
>If I adjust the county settings of my computer and say the decimal
>symbol must be an dot it
>works out fine, but this is not a very good solution because I dont
>want to be dependent of
>the system settings of a computer.
>I have tried to use the setlocale function with setlocale(LC_ALL,
>"English"). This didnt
>seem to work.
>Anybody has an clue?
>
I don't think that "English" is a standard locate. "C", on the other
hand, is, and may well do what you want since it is the standard
locale. What other locales are available is dependant on your system
so you would have to ask in a group dedicated to your implementation,
possibly a Linux group. One of my linux boxes appears to have locales
en_US and en_GB, for example, but they are not part of the C standard.
But be careful about calling setlocale(LC_ALL, "C"). This (or the
equivalent) is done at program startup. If your program is operating
in a different locale, it must be because there was another call to
setlocale() with different arguments, possibly setlocale(LC_ALL, ""),
which "specifies the locale-specific native environment". If you set
the locale to "C", you could change the behavior of other parts of the
program that depend on a native or other locale.
It's possible to save and restore the locale; setlocale() with a null
pointer as its second argument returns a pointer to a string
representing the current locale. You can query and save the current
locale, do your stuff, then set it back.
--
Keith Thompson (The_Other_Keith)
kst-u@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <* <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.