Modified locale tests for issue 1063 (#1363)
This commit is contained in:
parent
fe3c6ee2cb
commit
00470ccd12
|
@ -48,30 +48,34 @@ $locale = ($_SERVER['argv'][2] ?? '');
|
||||||
|
|
||||||
echo "**Begin**" . PHP_EOL;
|
echo "**Begin**" . PHP_EOL;
|
||||||
|
|
||||||
// Assuming LC_ALL is 'en_US.UTF-8', so is LC_CTYPE, except in PHP 8 (TODO)
|
// Assuming LC_ALL is 'en_US.UTF-8', but default LC_CTYPE and LC_MONETARY vary in various
|
||||||
// But default LC_MONETARY varies
|
// platforms and PHP versions, so only check when $setLocaleInfo is 2
|
||||||
$ctype = (PHP_MAJOR_VERSION == 8 && $setLocaleInfo == 0) ? 'C' : 'en_US.UTF-8';
|
|
||||||
switch ($setLocaleInfo) {
|
switch ($setLocaleInfo) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
$m = 'C'; $symbol = ''; $sep = '';
|
$symbol = ''; $sep = '';
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$m = 'en_US.UTF-8'; $symbol = '$'; $sep = ',';
|
$symbol = '$'; $sep = ',';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
die("Unexpected $setLocaleInfo\n");
|
die("Unexpected $setLocaleInfo\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$m1 = setlocale(LC_MONETARY, 0);
|
if ($setLocaleInfo == 2) {
|
||||||
if ($m !== $m1) {
|
$ctype = 'en_US.UTF-8';
|
||||||
echo "Unexpected LC_MONETARY: $m1" . PHP_EOL;
|
$m = 'en_US.UTF-8';
|
||||||
}
|
|
||||||
$c1 = setlocale(LC_CTYPE, 0);
|
$m1 = setlocale(LC_MONETARY, 0);
|
||||||
if ($ctype !== $c1) {
|
if ($m !== $m1) {
|
||||||
echo "Unexpected LC_CTYPE: $c1" . PHP_EOL;
|
echo "Unexpected LC_MONETARY: $m1" . PHP_EOL;
|
||||||
echo "LC_NUMERIC for $setLocaleInfo: " . setlocale(LC_NUMERIC, 0) . PHP_EOL;
|
}
|
||||||
|
$c1 = setlocale(LC_CTYPE, 0);
|
||||||
|
if ($ctype !== $c1) {
|
||||||
|
echo "Unexpected LC_CTYPE: $c1" . PHP_EOL;
|
||||||
|
echo "LC_NUMERIC for $setLocaleInfo: " . setlocale(LC_NUMERIC, 0) . PHP_EOL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set a different locale, if the input is not empty
|
// Set a different locale, if the input is not empty
|
||||||
|
|
|
@ -13,7 +13,7 @@ function fatalError($message)
|
||||||
die($message);
|
die($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function printMoney($amt, $info)
|
function printMoney($amt, $info)
|
||||||
{
|
{
|
||||||
// The money_format() function is deprecated in PHP 7.4, so use intl NumberFormatter
|
// The money_format() function is deprecated in PHP 7.4, so use intl NumberFormatter
|
||||||
$loc = setlocale(LC_MONETARY, 0);
|
$loc = setlocale(LC_MONETARY, 0);
|
||||||
|
@ -53,30 +53,34 @@ $locale = ($_SERVER['argv'][2] ?? '');
|
||||||
|
|
||||||
echo "**Begin**" . PHP_EOL;
|
echo "**Begin**" . PHP_EOL;
|
||||||
|
|
||||||
// Assuming LC_ALL is 'en_US.UTF-8', so is LC_CTYPE, except in PHP 8 (TODO)
|
// Assuming LC_ALL is 'en_US.UTF-8', but default LC_CTYPE and LC_MONETARY vary in various
|
||||||
// But default LC_MONETARY varies
|
// platforms and PHP versions, so only check when $setLocaleInfo is 2
|
||||||
$ctype = (PHP_MAJOR_VERSION == 8 && $setLocaleInfo == 0) ? 'C' : 'en_US.UTF-8';
|
|
||||||
switch ($setLocaleInfo) {
|
switch ($setLocaleInfo) {
|
||||||
case 0:
|
case 0:
|
||||||
case 1:
|
case 1:
|
||||||
$m = 'C'; $symbol = ''; $sep = '';
|
$symbol = ''; $sep = '';
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$m = 'en_US.UTF-8'; $symbol = '$'; $sep = ',';
|
$symbol = '$'; $sep = ',';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fatalError("Unexpected $setLocaleInfo\n");
|
fatalError("Unexpected $setLocaleInfo\n");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$m1 = setlocale(LC_MONETARY, 0);
|
if ($setLocaleInfo == 2) {
|
||||||
if ($m !== $m1) {
|
$ctype = 'en_US.UTF-8';
|
||||||
echo "Unexpected LC_MONETARY: $m1" . PHP_EOL;
|
$m = 'en_US.UTF-8';
|
||||||
}
|
|
||||||
$c1 = setlocale(LC_CTYPE, 0);
|
$m1 = setlocale(LC_MONETARY, 0);
|
||||||
if ($ctype !== $c1) {
|
if ($m !== $m1) {
|
||||||
echo "Unexpected LC_CTYPE: $c1" . PHP_EOL;
|
echo "Unexpected LC_MONETARY: $m1" . PHP_EOL;
|
||||||
echo "LC_NUMERIC for $setLocaleInfo: " . setlocale(LC_NUMERIC, 0) . PHP_EOL;
|
}
|
||||||
|
$c1 = setlocale(LC_CTYPE, 0);
|
||||||
|
if ($ctype !== $c1) {
|
||||||
|
echo "Unexpected LC_CTYPE: $c1" . PHP_EOL;
|
||||||
|
echo "LC_NUMERIC for $setLocaleInfo: " . setlocale(LC_NUMERIC, 0) . PHP_EOL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set a different locale, if the input is not empty
|
// Set a different locale, if the input is not empty
|
||||||
|
@ -86,7 +90,7 @@ if (!empty($locale)) {
|
||||||
if ($loc !== $locale) {
|
if ($loc !== $locale) {
|
||||||
echo "Unexpected $loc for LC_ALL " . PHP_EOL;
|
echo "Unexpected $loc for LC_ALL " . PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Currency symbol and thousands separator in Linux and macOS may be different
|
// Currency symbol and thousands separator in Linux and macOS may be different
|
||||||
if ($loc === 'de_DE.UTF-8') {
|
if ($loc === 'de_DE.UTF-8') {
|
||||||
$symbol = strtoupper(PHP_OS) === 'LINUX' ? '€' : 'Eu';
|
$symbol = strtoupper(PHP_OS) === 'LINUX' ? '€' : 'Eu';
|
||||||
|
|
Loading…
Reference in a new issue