472,958 Members | 2,367 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

decimal symbol problem (using libxml2)

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?

Cheerz, David

-----------------------------
xmlTextWriterPtr writer = NULL;
xmlDocPtr doc = NULL;
char xmlFilename[100] = "uitvoer.xml";

writer = xmlNewTextWriterDoc(&doc, 0);
if (NULL != writer)
{
xmlTextWriterStartDocument(writer, NULL, "ISO-8859-1", NULL);
xmlTextWriterStartElement(writer, BAD_CAST "Main");
xmlTextWriterWriteFormatElement(writer, BAD_CAST "getal", "%f",
10.12345);
xmlTextWriterEndElement(writer);
xmlFreeTextWriter(writer);
xmlSaveFormatFile(xmlFilename, doc, 1);
xmlFreeDoc(doc);
}

Jul 5 '06 #1
2 2485
corley wrote:
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.
Cheerz, David

-----------------------------
xmlTextWriterPtr writer = NULL;
xmlDocPtr doc = NULL;
<snip>

This looks like you are using the libxml2 library, which again is
non-standard and so off topic here (I use it myself, but I and all my
current customers will be set to either a British, USA or standard C
locale so I've not seen this problem). However, libxml2 has its own
mailing lists and it might be worth searching them.
http://xmlsoft.org/search.php?query=...submit=Search+...
returns a lot of hits which would be worth investigating.
--
Flash Gordon, living in interesting times.
Web site - http://home.flash-gordon.me.uk/
comp.lang.c posting guidelines and intro:
http://clc-wiki.net/wiki/Intro_to_clc
Jul 5 '06 #2
Flash Gordon <sp**@flash-gordon.me.ukwrites:
corley wrote:
>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) ks***@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.
Jul 5 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Ordz | last post by:
I want to write a program that will take a decimal with up to 4 places and convert it to 1/16 ths. I can sort of do that with: n = 375 * 16 / 1000 Print n; "/16" I am planning to use an input...
7
by: BA | last post by:
Hello, I have a string with a price in: "$14.95" I need to get it into a decimal. So I regex 'd the string and dumped the $. Debug mon shows a clean string "14.95" Then I do a...
0
by: Richard Taylor | last post by:
User-Agent: OSXnews 2.07 Xref: number1.nntp.dca.giganews.com comp.lang.python:437315 Hi I am trying to use py2app (http://undefined.org/python/) to package a gnome-python application...
0
by: Andrés Giraldo | last post by:
Hi! I have a a store procedure in SQL Server 2000 that returns a decimal field, if I run the sp in SQL Server it shows me the '.' as the decimal symbol, as is configured in the regional settings...
7
by: Oenone | last post by:
Can anyone explain why the following happens? \\\ Dim d1 As Decimal = CDec("100") Dim d2 As Decimal = CDec("100.00") MsgBox(d1.ToString) 'displays "100" MsgBox(d2.ToString) 'displays...
1
by: cesar.ortiz | last post by:
Hi all, I have created an example using libxml2 based in the code that appears in http://xmlsoft.org/python.html. My example processes an enough amount of html files to see that the memory...
1
by: Andrew Marlow | last post by:
guys, I have been using libxml2 with python with no problems for just over a week but now I come to see if my script will work in someone else's environment and the libxml2 import fails. I am...
6
by: saumya.agarwal | last post by:
Hi, I am using libxml2 for xml parsing. When the client application sends data to libxml2 in UTF-8 format, it works fine. But, I have a scenarion in which the client application sends data to...
1
by: Joza | last post by:
Hi everybody! I have question about setting decimal symbols... In some countries, for example in my country we use comma for decimal symbol, but in in some other countries it is decimal point....
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...

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.