public static function normalizeDigits($number, $keepNonDigits)
{
$normalizedDigits = "";
$numberAsArray = preg_split('/(?<!^)(?!$)/u', $number);
foreach ($numberAsArray as $character) {
if (is_numeric($character)) {
$normalizedDigits .= $character;
} elseif ($keepNonDigits) {
$normalizedDigits .= $character;
}
// If neither of the above are true, we remove this character.
// Check if we are in the unicode number range
if (array_key_exists($character, static::$numericCharacters)) {
$normalizedDigits .= static::$numericCharacters[$character];
}
}
return $normalizedDigits;
}