This is the mail archive of the mailing list for the glibc project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Handling numbers input/output in glibc

Behdad Esfahbod wrote on 2004-01-10:
> Problem statement:  In Persian (fa_IR) locale, we like to read
> and write numbers with Persian numerals (U+06F0..U+06F9).

To this I'd like to add the important additional explanation that you
made on 2004-01-06:

> The border between which numbers should be written with local
> digits, which with latin digits, is not quite clear.  For example
> in Persian we write every number with Persian digits, but I can
> see how we may write a price with US dollar currency sign with
> Latin digits.  Or Arab people may have their own desires about
> which numbers they would like to see in their local digits, which
> not.  So the decision better be left to each translation team,

The solution that is implemented for this is:
  - The application developer uses gettext() around all format strings that
    contain "%d".
  - gettext() looks up the translation in the Persian message catalog. It
    may contains "%Id" instead of "%d".
  - printf substitutes outdigits for those numbers that are output with "%Id".

This should be sufficient, isn't it?

> By now it should be clear that as it turns out from the
> definition, the "outdigit" digits should be used for output
> formatted by "%d".  In other words, the "%Id" should become the
> default behaviour.
> ...
> Proposed changes/extensions to glibc:
> - Make "%Id" behaviour default.  Same for "%If".
> - Deprecate "I" flag.
> - Having a flag "P" that outputs numbers in POSIX locale is
>   proposed.

This is not appropriate, because
  1. As you said above, it is not the desired behaviour in all cases.
  2. Many programs will break when sprintf(buf,"%d",0) is not "0" any more.
     Persian users would be those who would suffer. You won't succeed in
     asking thousands of program authors to use "%Pd" instead of "%d".


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]