I'm reading attribute fields in an XML document where the decimal point always is '.'
and the computer local may differ from this (in my own case it is ','
).
I tried to set the global FormatSettings.DecimalSeparator
to '.'
but it has no effect on the XML parser. This is a very compressed version of the problem.
_di_IXMLDocument Document;
_di_IXMLNode Node;
float Value;
Document = LoadXMLDocument("Test.xml");
Node = Document->DocumentElement;
FormatSettings.DecimalSeparator = '.';
Value = Node->GetAttribute("scale");
Assume this XML file.
<?xml version="1.0" encoding="utf-8"?>
<myroot scale="1.234">
</myroot>
After reading the attribute scale I always get the result striped on the '.' character resulting in Value = 1234 instead of 1.234.
The number of decimals are not constant, they can be 1 or 4 or anything in between. This also goes for the whole part, so dividing by 100 or 1000 will not solve the problem.
I would preferable have the OLEVariant to accept the '.'
as a decimal point (my local is ','
).
I had a look at SetLocalInfo()
but this will set the format for ALL applications. The getlocale()
function manipulates the current thread but I have not found a way to explicitly specify the character to use. It seems like it is only possible to select a code page or localization, as in a country.
EDIT
I tried to use setlocal()
and select English-US
as localization. Even if US are using '.'
as the decimal separator, the XML Parsers seems to ignore this.
If I manually change the '.'
to a ','
in the XML file, it works fine. But the XML file is a third party file, which I have no control of. So I really need to read it as it is with a '.'
decimal separator