List Info

Thread: decimal problem




decimal problem
user name
2006-12-12 08:28:03
Hello world, 

I am having a problem with the decimal symbol. The result of
writing a 
floating-point-number to an xml document 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 

[Source code listing]
----------------------------- 
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); 
}
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
decimal problem
user name
2006-12-12 09:21:34
2006/12/12, David <lordkaintlen.pl>:
> Hello world,
>
> I am having a problem with the decimal symbol. The
result of writing a
> floating-point-number to an xml document 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.

I don't think "English" is a valid locale, I think
you should use
"en_US" or similar.

Best regards
Aron Stansvik

>
> Anybody has an clue?
>
> Cheerz, David
>
> [Source code listing]
> -----------------------------
> 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);
> }
> _______________________________________________
> xml mailing list, project page  http://xmlsoft.org/
> xmlgnome.org
> http://mai
l.gnome.org/mailman/listinfo/xml
>
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xmlgnome.org
http://mai
l.gnome.org/mailman/listinfo/xml
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )