[fpc-pascal] "VAL" and i18n
Jonas Maebe
jonas.maebe at elis.ugent.be
Fri Jul 24 09:55:07 CEST 2009
On 24 Jul 2009, at 09:29, Torsten Bonde Christiansen wrote:
> After fiddling around with some local text i came across something
> odd. Is it true that the "val" function does not care for person
> i18n settings?
Yes.
> Trying to validate "1,2" (notice the comma - danish decimal separtor
> style) with val resulted in returning code = 2, i.e. that comma is
> the problem. Stepping through the code, it seem that in
> "fpc_Val_Real_ShortStr" the decimal separator is hardcoded to ".".
> Is this a bug or is this just the way "val" is intended to work?
It is the way val is intended to work. Use http://www.freepascal.org/docs-html/rtl/sysutils/floattostr.html
instead if you want to make use of the locale settings (do not
forget to use the "clocale" unit in your program if you are on a Unix
platform to initialise the locale settings, or manually specify a
TFormatSettings parameter to floattostr).
Jonas
More information about the fpc-pascal
mailing list