2024年6月17日(月) 15:56 Léa Gris <lea.g...@noiraude.net>:
> Le 16/06/2024 à 23:44, Zachary Santer écrivait :
> Anyway, this could be handled with existing bash string replacement feature:
>
> localeFormatted=3,1415
> declare -i numvar=${localeFormatted/,/.}

Is the radix character in an arbitrary locale ensured to be either `.'
or `,'? I think we should in general need to do

  declare -i numvar=${localeFormatted/[!0-9]/.}

Anyway, this is non-trivial for users. I anticipate that people in
typical locales won't care about it, so many scripts would do
`numvar=$localeFormatted` and are tested under en_US.UTF-8 or locales
with `.' being the radix character Then, those scripts are later
broken under random locales.

In my opinion, the locale-formatted strings should only appear in the
strings presented to users, such as in the output of `printf'. It is
easier and maintainable to normalize all the internal representations
to be the C floating-point literals.

--
Koichi

Reply via email to