Beware the decimal separator
The clash between decimal separators, double values and application culture already made Point type a victim. Today I found abound another one..
I had an iframe positioned above my silverlight control. Its dimensions was controlled from C# managed code (with the use of System.Windows.Browser library).
Or at least it should have been.
ERROR:
No matter I gave the right double values to set the iframe’s width, it just didn’t changed:
Iframe.SetStyleAttribute("width", value.ToString() + "px");
SOLUTION:
After a few rounds of debugging I found the solution. The problem was caused by the decimal separator being a comma instead of a point.
The fix is the same as with the Point type:
Iframe.SetStyleAttribute("width", value.ToString(System.Globalization.CultureInfo.InvariantCulture) + “px”);
[…] Beware the decimal separator Post a comment | Trackback URI […]
I did feel the pain last week: I had to implement an AWK script which handles well the input of a 4 GB file with mixed thousand and decimal separator, and handle well the output.
If you look up printf() in AWK you will find, that there is a ‘ option to it which handles the thousand separators. But I just can’t get it working for me: the escaping should have been ‘”‘”‘ and it had thrown an error all the time. So after a while I had implemented a TSEP function instead. And my hair went grey.