473,471 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 2516
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: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.