Re: locale, gui vs command line question?




On Mon, 1 Feb 2010, Freddie Unpenstein wrote:

On Sun, 31 Jan 2010, james morris wrote:
Why is store/change/restore of locale bad?

There's nothing at all wrong with it in the context you
specified -- i.e. you want to ensure that floating-point
values written to and read from file always use '.' as the
decimal separator. I do that in my app, gretl (also for
reasons of portability).

The problem would be the potential that the library may have
cached locale features under a different locale, wouldn't it?
[...]

If the locale were to unexpectedly change to one that uses a
multi-byte decimal point, a buffer overrun would certainly
occur.  In the opposing case, that same function would likely
write out a null character following the number.

OMG, multibyte decimal character!  Does that occur anywhere other
than Arabic?  And even with Arabic, would it actually be seen in a
sane locale setting on a contemporary computer?

IMO the practical case is translating between monobyte '.' and
',', which is easy.  Exotica could be dealt with as needed via
very careful programming (strlen(localeconv()->decimal_point)).

Allin Cottrell





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]