Menu

#369 (ok 2.11) Allow multibyte characters in number formatting

closed-accepted
Interface (183)
1
2007-08-21
2007-07-07
Edgaras
No

Currently PHP function number_format is not multibyte safe, so if in lang/*-utf-8.inc.php $number_thousands_separator I would use non-breaking space (\xc2\xa0) for thousands separator, then it would print only \xc2.

These language now uses space, but should use non breaking space.
czech
finnish
french
georgian
hungarian
latvian
lithuanian
polish
russian
slovak
swedish

Discussion

  • Edgaras

    Edgaras - 2007-07-07

    Patch

     
  • Marc Delisle

    Marc Delisle - 2007-07-09
    • assigned_to: nobody --> lem9
     
  • Marc Delisle

    Marc Delisle - 2007-07-09

    Logged In: YES
    user_id=210714
    Originator: NO

    Thanks Edgaras. I have 2 questions:

    1. In this part:

    + //number_format is not multibyte safe, str_replace is safe
    if ($length === 0) {
    - return number_format($value,
    - $comma,
    - $GLOBALS['number_decimal_separator'],
    - $GLOBALS['number_thousands_separator']);
    + return str_replace(',', $GLOBALS['number_thousands_separator'], number_format($value));

    why not using $GLOBALS['number_decimal_separator'] like you do here:

    - $value = number_format($value,
    - $comma,
    - $GLOBALS['number_decimal_separator'],
    - $GLOBALS['number_thousands_separator']);
    + //number_format is not multibyte safe, str_replace is safe
    + $value = str_replace(array(',', '.'),
    + array($GLOBALS['number_thousands_separator'], $GLOBALS['number_decimal_separator']),
    + number_format($value, $comma));
    ==========

    2. Could you attach here an example of this non-breaking space as a patch for one of these languages?

     
  • Edgaras

    Edgaras - 2007-07-09

    Logged In: YES
    user_id=1161712
    Originator: YES

    1. I thought that it's always integer when length=0, so it's never decimal part, but now I think you are right. Use
    return str_replace(array(',', '.'),
    array($GLOBALS['number_thousands_separator'], $GLOBALS['number_decimal_separator']),
    number_format($value, $comma));

    2. Here is patch for all languages where currently is space (Lithuanians also use ' ' and ',', so changed them also).

     
  • Edgaras

    Edgaras - 2007-07-09

    Logged In: YES
    user_id=1161712
    Originator: YES

    File Added: nbsp.patch

     
  • Edgaras

    Edgaras - 2007-07-09

    Language files patch

     
  • Marc Delisle

    Marc Delisle - 2007-07-09
    • milestone: 284145 --> For_immediate_release
    • priority: 5 --> 1
    • summary: Allow multibyte characters in number formatting --> (ok 2.11) Allow multibyte characters in number formatting
    • status: open --> open-accepted
     
  • Marc Delisle

    Marc Delisle - 2007-07-09

    Logged In: YES
    user_id=210714
    Originator: NO

    Merged in subversion, thanks.

     
  • Marc Delisle

    Marc Delisle - 2007-08-21
    • status: open-accepted --> closed-accepted