diff --git a/4dev/tests/CoreLibsConvertStringsTest.php b/4dev/tests/CoreLibsConvertStringsTest.php index 7e71355f..9f054928 100644 --- a/4dev/tests/CoreLibsConvertStringsTest.php +++ b/4dev/tests/CoreLibsConvertStringsTest.php @@ -97,7 +97,13 @@ final class CoreLibsConvertStringsTest extends TestCase '2-2', null, '12--3-4' - ] + ], + 'mutltibyte string' => [ + 'あいうえ', + '2-2', + null, + 'あいうえ' + ], ]; } diff --git a/www/admin/class_test.strings.php b/www/admin/class_test.strings.php index 7681110d..4e08b2fa 100644 --- a/www/admin/class_test.strings.php +++ b/www/admin/class_test.strings.php @@ -64,6 +64,13 @@ $string = '1234'; print "Convert: $string with $split to: " . \CoreLibs\Convert\Strings::splitFormatString($string, $split) . "
"; +$split = '2-2'; +$string = 'あいうえ'; +print "Convert: $string with $split to: " + . \CoreLibs\Convert\Strings::splitFormatString($string, $split) + . "
"; + + // error message print $log->printErrorMsg(); diff --git a/www/lib/CoreLibs/Convert/Strings.php b/www/lib/CoreLibs/Convert/Strings.php index 324083af..a820fcdc 100644 --- a/www/lib/CoreLibs/Convert/Strings.php +++ b/www/lib/CoreLibs/Convert/Strings.php @@ -35,6 +35,14 @@ class Strings if (empty($split_format)) { return $value; } + // if not in the valid ASCII character range + // might need some tweaking + if (preg_match('/[^\x20-\x7e]/', $value)) { + return $value; + } + // if (!mb_check_encoding($value, 'ASCII')) { + // return $value; + // } $split_list = preg_split( // allowed split characters "/([" . $split_charcters . "]{1})/",