@@ -13,7 +13,7 @@ function fatalError($message)
1313 die ($ message );
1414}
1515
16- function printMoney ($ amt , $ info )
16+ function printMoney ($ amt , $ info )
1717{
1818 // The money_format() function is deprecated in PHP 7.4, so use intl NumberFormatter
1919 $ loc = setlocale (LC_MONETARY , 0 );
@@ -53,30 +53,34 @@ function printCal($date)
5353
5454echo "**Begin** " . PHP_EOL ;
5555
56- // Assuming LC_ALL is 'en_US.UTF-8', so is LC_CTYPE, except in PHP 8 (TODO)
57- // But default LC_MONETARY varies
58- $ ctype = (PHP_MAJOR_VERSION == 8 && $ setLocaleInfo == 0 ) ? 'C ' : 'en_US.UTF-8 ' ;
56+ // Assuming LC_ALL is 'en_US.UTF-8', but default LC_CTYPE and LC_MONETARY vary in various
57+ // platforms and PHP versions, so only check when $setLocaleInfo is 2
5958switch ($ setLocaleInfo ) {
6059 case 0 :
6160 case 1 :
62- $ m = ' C ' ; $ symbol = '' ; $ sep = '' ;
61+ $ symbol = '' ; $ sep = '' ;
6362 break ;
6463 case 2 :
65- $ m = ' en_US.UTF-8 ' ; $ symbol = '$ ' ; $ sep = ', ' ;
64+ $ symbol = '$ ' ; $ sep = ', ' ;
6665 break ;
6766 default :
6867 fatalError ("Unexpected $ setLocaleInfo \n" );
6968 break ;
7069}
7170
72- $ m1 = setlocale (LC_MONETARY , 0 );
73- if ($ m !== $ m1 ) {
74- echo "Unexpected LC_MONETARY: $ m1 " . PHP_EOL ;
75- }
76- $ c1 = setlocale (LC_CTYPE , 0 );
77- if ($ ctype !== $ c1 ) {
78- echo "Unexpected LC_CTYPE: $ c1 " . PHP_EOL ;
79- echo "LC_NUMERIC for $ setLocaleInfo: " . setlocale (LC_NUMERIC , 0 ) . PHP_EOL ;
71+ if ($ setLocaleInfo == 2 ) {
72+ $ ctype = 'en_US.UTF-8 ' ;
73+ $ m = 'en_US.UTF-8 ' ;
74+
75+ $ m1 = setlocale (LC_MONETARY , 0 );
76+ if ($ m !== $ m1 ) {
77+ echo "Unexpected LC_MONETARY: $ m1 " . PHP_EOL ;
78+ }
79+ $ c1 = setlocale (LC_CTYPE , 0 );
80+ if ($ ctype !== $ c1 ) {
81+ echo "Unexpected LC_CTYPE: $ c1 " . PHP_EOL ;
82+ echo "LC_NUMERIC for $ setLocaleInfo: " . setlocale (LC_NUMERIC , 0 ) . PHP_EOL ;
83+ }
8084}
8185
8286// Set a different locale, if the input is not empty
@@ -86,7 +90,7 @@ function printCal($date)
8690 if ($ loc !== $ locale ) {
8791 echo "Unexpected $ loc for LC_ALL " . PHP_EOL ;
8892 }
89-
93+
9094 // Currency symbol and thousands separator in Linux and macOS may be different
9195 if ($ loc === 'de_DE.UTF-8 ' ) {
9296 $ symbol = strtoupper (PHP_OS ) === 'LINUX ' ? '€ ' : 'Eu ' ;
0 commit comments