Skip to content

Commit

Permalink
Number formatter update.
Browse files Browse the repository at this point in the history
Changelog excerpt:
- Added Ge'ez/Ethiopic support to the number formatter and performed some
  minor refactoring.
  • Loading branch information
Maikuolan committed Jun 26, 2024
1 parent 609b5b5 commit 7052384
Show file tree
Hide file tree
Showing 3 changed files with 114 additions and 105 deletions.
3 changes: 3 additions & 0 deletions Changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ found at:
- [2024.06.26; Bug-fix; Maikuolan]: Number formatter showing some Armenian
numerals incorrectly; Fixed.

- [2024.06.26; Maikuolan]: Added Ge'ez/Ethiopic support to the number formatter
and performed some minor refactoring.

=== Version/Release 2.12.0 ===
MINOR RELEASE.

Expand Down
105 changes: 55 additions & 50 deletions _docs/NumberFormatter.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Value | `ConversionSet` | `GroupSeparator` | `GroupSize` | `GroupOffset` | `Deci
`Chinese-Traditional-Financial` *[†4]* | `ChineseTraditionalFinancial` | (empty) | (n/a) | (n/a) | ``<br />(U+9EDE) | `10`
`Chinese-Traditional` *[†4]* | `ChineseTraditional` | (empty) | (n/a) | (n/a) | ``<br />(U+9EDE) | `10`
`Fullwidth` | `Fullwidth` | (empty) | (n/a) | (n/a) | `.`<br />(decimal) | `10`
`Geez` *[†3]* | `Geez` | (empty) | (n/a) | (n/a) | (empty) | `10`
`Hebrew` *[†3] [†4]* | `Hebrew` | (empty) | (n/a) | (n/a) | (empty) | `10`
`India-1` | `Western` | `,`<br />(comma) | `2` | `-1` | `.`<br />(decimal) | `10`
`India-2` or `Devanagari` | `Devanagari` | `,`<br />(comma) | `2` | `-1` | `.`<br />(decimal) | `10`
Expand Down Expand Up @@ -115,6 +116,7 @@ $Formats = [
'Chinese-Traditional',
'Chinese-Traditional-Financial',
'Fullwidth',
'Geez',
'Hebrew',
'India-1',
'India-2',
Expand Down Expand Up @@ -146,62 +148,64 @@ $Formats = [
'Tibetan'
];

echo "Format | `\$Obj->format('1234567.89', 2)` | `\$Obj->format('10203040.50607080', 5)` | `\$Obj->format('100.75', 3)`\n---|---|---|---\n";
echo "Format | `\$Obj->format('1234567.89', 2)` | `\$Obj->format('10203040.50607080', 5)` | `\$Obj->format('100.75', 3)` | `\$Obj->format('99999999', 0)`\n:--|--:|--:|--:|--:\n";

foreach ($Formats as $Format) {
$Obj = new \Maikuolan\Common\NumberFormatter($Format);
echo '`' . $Format . '` | `' . $Obj->format('1234567.89', 2) . '` | `' . $Obj->format('10203040.50607080', 5) . '` | `' . $Obj->format('100.75', 3) . "`\n";
echo '`' . $Format . '` | `' . $Obj->format('1234567.89', 2) . '` | `' . $Obj->format('10203040.50607080', 5) . '` | `' . $Obj->format('100.75', 3) . '` | `' . $Obj->format('99999999', 0) . "`\n";
}
```

Output:

Format | `$Obj->format('1234567.89', 2)` | `$Obj->format('10203040.50607080', 5)` | `$Obj->format('100.75', 3)`
:--|--:|--:|--:
`Arabic-1` | `١٢٣٤٥٦٧٫٨٩` | `١٠٢٠٣٠٤٠٫٥٠٦٠٧` | `١٠٠٫٧٥٠`
`Arabic-2` | `١٬٢٣٤٬٥٦٧٫٨٩` | `١٠٬٢٠٣٬٠٤٠٫٥٠٦٠٧` | `١٠٠٫٧٥٠`
`Arabic-3` | `۱٬۲۳۴٬۵۶۷٫۸۹` | `۱۰٬۲۰۳٬۰۴۰٫۵۰۶۰۷` | `۱۰۰٫۷۵۰`
`Arabic-4` | `۱۲٬۳۴٬۵۶۷٫۸۹` | `۱٬۰۲٬۰۳٬۰۴۰٫۵۰۶۰۷` | `۱۰۰٫۷۵۰`
`Armenian` | `Ռ̅Մ̅Լ̅ՏՇԿԷ` | `Մ̅ՎԽ` | `Ճ`
`Base-12` | `4b6547.a8` | `3500654.60a5a` | `84.900`
`Base-16` | `12d687.e3` | `9bafa0.818dd` | `64.c00`
`Bengali-1` | `১২,৩৪,৫৬৭.৮৯` | `১,০২,০৩,০৪০.৫০৬০৭` | `১০০.৭৫০`
`Burmese-1` | `၁၂၃၄၅၆၇.၈၉` | `၁၀၂၀၃၀၄၀.၅၀၆၀၇` | `၁၀၀.၇၅၀`
`China-1` | `123,4567.89` | `1020,3040.50607` | `100.750`
`Chinese-Simplified` | `一百二十三万四千五百六十七点八九` | `一千二十三千四十点五〇六〇七` | `一百点七五〇`
`Chinese-Simplified-Financial` | `壹佰贰拾叁萬肆仟伍佰陆拾柒点捌玖` | `壹仟贰拾叁仟肆拾点伍零陆零柒` | `壹佰点柒伍零`
`Chinese-Traditional` | `一百二十三萬四千五百六十七點八九` | `一千二十三千四十點五零六零七` | `一百點七五零`
`Chinese-Traditional-Financial` | `壹佰貳拾叄萬肆仟伍佰陸拾柒點捌玖` | `壹仟貳拾叄仟肆拾點伍零陸零柒` | `壹佰點柒伍零`
`Fullwidth` | `1234567.89` | `10203040.50607` | `100.750`
`Hebrew` | `א׳׳ב׳קג׳יד׳ךסז` | `א׳י׳ב׳קג׳מ` | `ק`
`India-1` | `12,34,567.89` | `1,02,03,040.50607` | `100.750`
`India-2` | `१२,३४,५६७.८९` | `१,०२,०३,०४०.५०६०७` | `१००.७५०`
`India-3` | `૧૨,૩૪,૫૬૭.૮૯` | `૧,૦૨,૦૩,૦૪૦.૫૦૬૦૭` | `૧૦૦.૭૫૦`
`India-4` | `੧੨,੩੪,੫੬੭.੮੯` | `੧,੦੨,੦੩,੦੪੦.੫੦੬੦੭` | `੧੦੦.੭੫੦`
`India-5` | `೧೨,೩೪,೫೬೭.೮೯` | `೧,೦೨,೦೩,೦೪೦.೫೦೬೦೭` | `೧೦೦.೭೫೦`
`India-6` | `౧౨,౩౪,౫౬౭.౮౯` | `౧,౦౨,౦౩,౦౪౦.౫౦౬౦౭` | `౧౦౦.౭౫౦`
`Japanese` | `百万二十万三万四千五百六十七・八九分` | `千万二十万三千四十・五六厘七糸` | `百・七五分`
`Javanese` | `꧑꧒꧓꧔꧕꧖꧗.꧘꧙` | `꧑꧐꧒꧐꧓꧐꧔꧐.꧕꧐꧖꧐꧗` | `꧑꧐꧐.꧗꧕꧐`
`Kaktovik` | `𝋇𝋎𝋆𝋈𝋇.𝋑𝋐` | `𝋃𝋃𝋏𝋇𝋌𝋀.𝋊𝋂𝋈𝋋𝋆` | `𝋅𝋀.𝋏𝋀𝋀`
`Khmer-1` | `១.២៣៤.៥៦៧,៨៩` | `១០.២០៣.០៤០,៥០៦០៧` | `១០០,៧៥០`
`Lao-1` | `໑໒໓໔໕໖໗.໘໙` | `໑໐໒໐໓໐໔໐.໕໐໖໐໗` | `໑໐໐.໗໕໐`
`Latin-1` | `1,234,567.89` | `10,203,040.50607` | `100.750`
`Latin-2` | `1 234 567.89` | `10 203 040.50607` | `100.750`
`Latin-3` | `1.234.567,89` | `10.203.040,50607` | `100,750`
`Latin-4` | `1 234 567,89` | `10 203 040,50607` | `100,750`
`Latin-5` | `1,234,567·89` | `10,203,040·50607` | `100·750`
`Mayan` | `𝋧𝋮𝋦𝋨𝋧.𝋱𝋰` | `𝋣𝋣𝋯𝋧𝋬𝋠.𝋪𝋢𝋨𝋫𝋦` | `𝋥𝋠.𝋯𝋠𝋠`
`Mongolian` | `᠑᠒᠓᠔᠕᠖᠗.᠘᠙` | `᠑᠐᠒᠐᠓᠐᠔᠐.᠕᠐᠖᠐᠗` | `᠑᠐᠐.᠗᠕᠐`
`NoSep-1` | `1234567.89` | `10203040.50607` | `100.750`
`NoSep-2` | `1234567,89` | `10203040,50607` | `100,750`
`Odia` | `୧୨୩୪୫୬୭.୮୯` | `୧୦୨୦୩୦୪୦.୫୦୬୦୭` | `୧୦୦.୭୫୦`
`Roman` | `M̅C̅C̅X̅X̅X̅I̅V̅DLXVII` | `C̅C̅MMMXL` | `C`
`SDN-Dwiggins` | `4E6,547;X8` | `3,500,654;60X5X` | `84;900`
`SDN-Pitman` | `4↋6,547;↊8` | `3,500,654;60↊5↊` | `84;900`
`Tamil` | `௲௲௨௱௲௩௰௲௪௲௫௱௬௰௭` | `௰௲௲௨௱௲௩௲௪௰` | ``
`Thai-1` | `๑,๒๓๔,๕๖๗.๘๙` | `๑๐,๒๐๓,๐๔๐.๕๐๖๐๗` | `๑๐๐.๗๕๐`
`Thai-2` | `๑๒๓๔๕๖๗.๘๙` | `๑๐๒๐๓๐๔๐.๕๐๖๐๗` | `๑๐๐.๗๕๐`
`Tibetan` | `༡༢༣༤༥༦༧.༨༩` | `༡༠༢༠༣༠༤༠.༥༠༦༠༧` | `༡༠༠.༧༥༠`
Format | `$Obj->format('1234567.89', 2)` | `$Obj->format('10203040.50607080', 5)` | `$Obj->format('100.75', 3)` | `$Obj->format('99999999', 0)`
:--|--:|--:|--:|--:
`Arabic-1` | `١٢٣٤٥٦٧٫٨٩` | `١٠٢٠٣٠٤٠٫٥٠٦٠٧` | `١٠٠٫٧٥٠` | `٩٩٩٩٩٩٩٩`
`Arabic-2` | `١٬٢٣٤٬٥٦٧٫٨٩` | `١٠٬٢٠٣٬٠٤٠٫٥٠٦٠٧` | `١٠٠٫٧٥٠` | `٩٩٬٩٩٩٬٩٩٩`
`Arabic-3` | `۱٬۲۳۴٬۵۶۷٫۸۹` | `۱۰٬۲۰۳٬۰۴۰٫۵۰۶۰۷` | `۱۰۰٫۷۵۰` | `۹۹٬۹۹۹٬۹۹۹`
`Arabic-4` | `۱۲٬۳۴٬۵۶۷٫۸۹` | `۱٬۰۲٬۰۳٬۰۴۰٫۵۰۶۰۷` | `۱۰۰٫۷۵۰` | `۹٬۹۹٬۹۹٬۹۹۹`
`Armenian` | `Ճ̅Ի̅Գ̅ՏՇԿԷ` | `Ռ̅Ի̅ՎԽ` | `Ճ` | `Ք̅Ջ̅Ղ̅Թ̅ՔՋՂԹ`
`Base-12` | `4b6547.a8` | `3500654.60a5a` | `84.900` | `295a6453`
`Base-16` | `12d687.e3` | `9bafa0.818dd` | `64.c00` | `5f5e0ff`
`Bengali-1` | `১২,৩৪,৫৬৭.৮৯` | `১,০২,০৩,০৪০.৫০৬০৭` | `১০০.৭৫০` | `৯,৯৯,৯৯,৯৯৯`
`Burmese-1` | `၁၂၃၄၅၆၇.၈၉` | `၁၀၂၀၃၀၄၀.၅၀၆၀၇` | `၁၀၀.၇၅၀` | `၉၉၉၉၉၉၉၉`
`China-1` | `123,4567.89` | `1020,3040.50607` | `100.750` | `9999,9999`
`Chinese-Simplified` | `一百二十三万四千五百六十七点八九` | `一千二十三千四十点五〇六〇七` | `一百点七五〇` | `九千九百九十九万九千九百九十九`
`Chinese-Simplified-Financial` | `壹佰贰拾叁萬肆仟伍佰陆拾柒点捌玖` | `壹仟贰拾叁仟肆拾点伍零陆零柒` | `壹佰点柒伍零` | `玖仟玖佰玖拾玖萬玖仟玖佰玖拾玖`
`Chinese-Traditional` | `一百二十三萬四千五百六十七點八九` | `一千二十三千四十點五零六零七` | `一百點七五零` | `九千九百九十九萬九千九百九十九`
`Chinese-Traditional-Financial` | `壹佰貳拾叄萬肆仟伍佰陸拾柒點捌玖` | `壹仟貳拾叄仟肆拾點伍零陸零柒` | `壹佰點柒伍零` | `玖仟玖佰玖拾玖萬玖仟玖佰玖拾玖`
`Fullwidth` | `1234567.89` | `10203040.50607` | `100.750` | `99999999`
`Geez` | `፻፳፫፼፵፭፻፷፯` | `፲፻፳፼፴፻፵` | `` | `፺፱፻፺፱፼፺፱፻፺፱`
`Hebrew` | `א׳׳ב׳קג׳יד׳ךסז` | `א׳י׳ב׳קג׳מ` | `ק` | `ט׳י׳ט׳׳ט׳קט׳יט׳ץצט`
`India-1` | `12,34,567.89` | `1,02,03,040.50607` | `100.750` | `9,99,99,999`
`India-2` | `१२,३४,५६७.८९` | `१,०२,०३,०४०.५०६०७` | `१००.७५०` | `९,९९,९९,९९९`
`India-3` | `૧૨,૩૪,૫૬૭.૮૯` | `૧,૦૨,૦૩,૦૪૦.૫૦૬૦૭` | `૧૦૦.૭૫૦` | `૯,૯૯,૯૯,૯૯૯`
`India-4` | `੧੨,੩੪,੫੬੭.੮੯` | `੧,੦੨,੦੩,੦੪੦.੫੦੬੦੭` | `੧੦੦.੭੫੦` | `੯,੯੯,੯੯,੯੯੯`
`India-5` | `೧೨,೩೪,೫೬೭.೮೯` | `೧,೦೨,೦೩,೦೪೦.೫೦೬೦೭` | `೧೦೦.೭೫೦` | `೯,೯೯,೯೯,೯೯೯`
`India-6` | `౧౨,౩౪,౫౬౭.౮౯` | `౧,౦౨,౦౩,౦౪౦.౫౦౬౦౭` | `౧౦౦.౭౫౦` | `౯,౯౯,౯౯,౯౯౯`
`Japanese` | `百万二十万三万四千五百六十七・八九分` | `千万二十万三千四十・五六厘七糸` | `百・七五分` | `九千万九百万九十万九万九千九百九十九`
`Javanese` | `꧑꧒꧓꧔꧕꧖꧗.꧘꧙` | `꧑꧐꧒꧐꧓꧐꧔꧐.꧕꧐꧖꧐꧗` | `꧑꧐꧐.꧗꧕꧐` | `꧙꧙꧙꧙꧙꧙꧙꧙`
`Kaktovik` | `𝋇𝋎𝋆𝋈𝋇.𝋑𝋐` | `𝋃𝋃𝋏𝋇𝋌𝋀.𝋊𝋂𝋈𝋋𝋆` | `𝋅𝋀.𝋏𝋀𝋀` | `𝋁𝋋𝋄𝋓𝋓𝋓𝋓`
`Khmer-1` | `១.២៣៤.៥៦៧,៨៩` | `១០.២០៣.០៤០,៥០៦០៧` | `១០០,៧៥០` | `៩៩.៩៩៩.៩៩៩`
`Lao-1` | `໑໒໓໔໕໖໗.໘໙` | `໑໐໒໐໓໐໔໐.໕໐໖໐໗` | `໑໐໐.໗໕໐` | `໙໙໙໙໙໙໙໙`
`Latin-1` | `1,234,567.89` | `10,203,040.50607` | `100.750` | `99,999,999`
`Latin-2` | `1 234 567.89` | `10 203 040.50607` | `100.750` | `99 999 999`
`Latin-3` | `1.234.567,89` | `10.203.040,50607` | `100,750` | `99.999.999`
`Latin-4` | `1 234 567,89` | `10 203 040,50607` | `100,750` | `99 999 999`
`Latin-5` | `1,234,567·89` | `10,203,040·50607` | `100·750` | `99,999,999`
`Mayan` | `𝋧𝋮𝋦𝋨𝋧.𝋱𝋰` | `𝋣𝋣𝋯𝋧𝋬𝋠.𝋪𝋢𝋨𝋫𝋦` | `𝋥𝋠.𝋯𝋠𝋠` | `𝋡𝋫𝋤𝋳𝋳𝋳𝋳`
`Mongolian` | `᠑᠒᠓᠔᠕᠖᠗.᠘᠙` | `᠑᠐᠒᠐᠓᠐᠔᠐.᠕᠐᠖᠐᠗` | `᠑᠐᠐.᠗᠕᠐` | `᠙᠙᠙᠙᠙᠙᠙᠙`
`NoSep-1` | `1234567.89` | `10203040.50607` | `100.750` | `99999999`
`NoSep-2` | `1234567,89` | `10203040,50607` | `100,750` | `99999999`
`Odia` | `୧୨୩୪୫୬୭.୮୯` | `୧୦୨୦୩୦୪୦.୫୦୬୦୭` | `୧୦୦.୭୫୦` | `୯୯୯୯୯୯୯୯`
`Roman` | `M̅C̅C̅X̅X̅X̅I̅V̅DLXVII` | `C̅C̅MMMXL` | `C` | `C̅M̅X̅C̅I̅X̅CMXCIX`
`SDN-Dwiggins` | `4E6,547;X8` | `3,500,654;60X5X` | `84;900` | `29,5X6,453`
`SDN-Pitman` | `4↋6,547;↊8` | `3,500,654;60↊5↊` | `84;900` | `29,5↊6,453`
`Tamil` | `௲௲௨௱௲௩௰௲௪௲௫௱௬௰௭` | `௰௲௲௨௱௲௩௲௪௰` | `` | `௯௰௲௲௯௲௲௯௱௲௯௰௲௯௲௯௱௯௰௯`
`Thai-1` | `๑,๒๓๔,๕๖๗.๘๙` | `๑๐,๒๐๓,๐๔๐.๕๐๖๐๗` | `๑๐๐.๗๕๐` | `๙๙,๙๙๙,๙๙๙`
`Thai-2` | `๑๒๓๔๕๖๗.๘๙` | `๑๐๒๐๓๐๔๐.๕๐๖๐๗` | `๑๐๐.๗๕๐` | `๙๙๙๙๙๙๙๙`
`Tibetan` | `༡༢༣༤༥༦༧.༨༩` | `༡༠༢༠༣༠༤༠.༥༠༦༠༧` | `༡༠༠.༧༥༠` | `༩༩༩༩༩༩༩༩`


#### getSetJSON method.

Expand Down Expand Up @@ -235,7 +239,7 @@ Currently supported values:
Value | Description
---|---
`Western` | Standard numerals (0-9), alternatively known as Western Arabic numerals, Arabic numerals, Hindu-Arabic numerals, etc.
`Armenian` | Armenian numerals. *(Fractions not supported. Range limit: 1 ~ 9,999,999).*
`Armenian` | Armenian numerals. *(Fractions not supported. Range limit: 1 ~ 99,999,999).*
`Burmese` | Burmese numerals.
`ChineseSimplifiedFinancial` | Financial simplified Chinese numerals. *(Range upper limit: 10<sup>^48</sup>-1).*
`ChineseSimplified` | Standard simplified Chinese numerals. *(Range upper limit: 10<sup>^48</sup>-1).*
Expand All @@ -244,6 +248,7 @@ Value | Description
`Devanagari` | Devanagari numerals.
`Eastern` | Eastern Arabic numerals.
`Fullwidth` | Fullwidth numerals.
`Geez` | Ge'ez/Ethiopic numerals. *(Fractions not supported. Range lower limit: 1).*
`Gujarati` | Gujarati numerals.
`Gurmukhi` | Gurmukhi numerals.
`Hebrew` | Hebrew numerals. *(Fractions not supported. Range limit: 1 ~ 10<sup>^16</sup>-1).*
Expand Down Expand Up @@ -542,4 +547,4 @@ Base 36: a.i000 ~ 74.9000
---


Last Updated: 29 December 2023 (2023.12.29).
Last Updated: 26 June 2024 (2024.06.26).
Loading

0 comments on commit 7052384

Please sign in to comment.