<?php
$examples = array(
'Valid ASCII' => array("a", true),
'Valid 2 Octet Sequence' => array("\xc3\xb1", true),
'Invalid 2 Octet Sequence' => array("\xc3\x28", false),
'Invalid Sequence Identifier' => array("\xa0\xa1", false),
'Valid 3 Octet Sequence' => array("\xe2\x82\xa1", true),
'Invalid 3 Octet Sequence (in 2nd Octet)' => array("\xe2\x28\xa1", false),
'Invalid 3 Octet Sequence (in 3rd Octet)' => array("\xe2\x82\x28", false),
'Valid 4 Octet Sequence' => array("\xf0\x90\x8c\xbc", true),
'Invalid 4 Octet Sequence (in 2nd Octet)' => array("\xf0\x28\x8c\xbc", false),
'Invalid 4 Octet Sequence (in 3rd Octet)' => array("\xf0\x90\x28\xbc", false),
'Invalid 4 Octet Sequence (in 4th Octet)' => array("\xf0\x28\x8c\x28", false),
'Valid 5 Octet Sequence (but not Unicode!)' => array("\xf8\xa1\xa1\xa1\xa1", false),
'Valid 6 Octet Sequence (but not Unicode!)' => array("\xfc\xa1\xa1\xa1\xa1\xa1", false),
);
function checkWithPreg($str) {
return preg_match('//u', $str);
}
function checkWithMbstring($str) {
return mb_check_encoding($str, 'UTF-8');
}
function test($actual, $expected, $title) {
echo $actual == $expected ? "[Success]" : "[Fail]";
echo " $title\n";
}
function runTests($method) {
global $examples;
foreach($examples as $title => $arr) {
list($str, $bool) = $arr;
test($method($str), $bool, $title);
}
}
echo "Checking with PCRE u modifier\n";
runTests('checkWithPreg');
echo "\n";
echo "Checking with mb_check_encoding\n";
runTests('checkWithMbstring');
- Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.36, 5.6.0 - 5.6.28, 7.0.0 - 7.0.20, 7.1.0 - 7.1.25, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.27, 8.2.0 - 8.2.17, 8.3.0 - 8.3.4
- Checking with PCRE u modifier
[Success] Valid ASCII
[Success] Valid 2 Octet Sequence
[Success] Invalid 2 Octet Sequence
[Success] Invalid Sequence Identifier
[Success] Valid 3 Octet Sequence
[Success] Invalid 3 Octet Sequence (in 2nd Octet)
[Success] Invalid 3 Octet Sequence (in 3rd Octet)
[Success] Valid 4 Octet Sequence
[Success] Invalid 4 Octet Sequence (in 2nd Octet)
[Success] Invalid 4 Octet Sequence (in 3rd Octet)
[Success] Invalid 4 Octet Sequence (in 4th Octet)
[Success] Valid 5 Octet Sequence (but not Unicode!)
[Success] Valid 6 Octet Sequence (but not Unicode!)
Checking with mb_check_encoding
[Success] Valid ASCII
[Success] Valid 2 Octet Sequence
[Success] Invalid 2 Octet Sequence
[Success] Invalid Sequence Identifier
[Success] Valid 3 Octet Sequence
[Success] Invalid 3 Octet Sequence (in 2nd Octet)
[Success] Invalid 3 Octet Sequence (in 3rd Octet)
[Success] Valid 4 Octet Sequence
[Success] Invalid 4 Octet Sequence (in 2nd Octet)
[Success] Invalid 4 Octet Sequence (in 3rd Octet)
[Success] Invalid 4 Octet Sequence (in 4th Octet)
[Success] Valid 5 Octet Sequence (but not Unicode!)
[Success] Valid 6 Octet Sequence (but not Unicode!)
- Output for 4.4.9, 5.2.5 - 5.2.17, 5.3.0 - 5.3.29
- Checking with PCRE u modifier
[Success] Valid ASCII
[Success] Valid 2 Octet Sequence
[Success] Invalid 2 Octet Sequence
[Success] Invalid Sequence Identifier
[Success] Valid 3 Octet Sequence
[Success] Invalid 3 Octet Sequence (in 2nd Octet)
[Success] Invalid 3 Octet Sequence (in 3rd Octet)
[Success] Valid 4 Octet Sequence
[Success] Invalid 4 Octet Sequence (in 2nd Octet)
[Success] Invalid 4 Octet Sequence (in 3rd Octet)
[Success] Invalid 4 Octet Sequence (in 4th Octet)
[Success] Valid 5 Octet Sequence (but not Unicode!)
[Success] Valid 6 Octet Sequence (but not Unicode!)
Checking with mb_check_encoding
[Success] Valid ASCII
[Success] Valid 2 Octet Sequence
[Success] Invalid 2 Octet Sequence
[Success] Invalid Sequence Identifier
[Success] Valid 3 Octet Sequence
[Success] Invalid 3 Octet Sequence (in 2nd Octet)
[Success] Invalid 3 Octet Sequence (in 3rd Octet)
[Success] Valid 4 Octet Sequence
[Success] Invalid 4 Octet Sequence (in 2nd Octet)
[Success] Invalid 4 Octet Sequence (in 3rd Octet)
[Success] Invalid 4 Octet Sequence (in 4th Octet)
[Fail] Valid 5 Octet Sequence (but not Unicode!)
[Fail] Valid 6 Octet Sequence (but not Unicode!)
- Output for 4.4.5 - 4.4.8, 5.2.1 - 5.2.4
- Checking with PCRE u modifier
[Success] Valid ASCII
[Success] Valid 2 Octet Sequence
[Success] Invalid 2 Octet Sequence
[Success] Invalid Sequence Identifier
[Success] Valid 3 Octet Sequence
[Success] Invalid 3 Octet Sequence (in 2nd Octet)
[Success] Invalid 3 Octet Sequence (in 3rd Octet)
[Success] Valid 4 Octet Sequence
[Success] Invalid 4 Octet Sequence (in 2nd Octet)
[Success] Invalid 4 Octet Sequence (in 3rd Octet)
[Success] Invalid 4 Octet Sequence (in 4th Octet)
[Fail] Valid 5 Octet Sequence (but not Unicode!)
[Fail] Valid 6 Octet Sequence (but not Unicode!)
Checking with mb_check_encoding
[Success] Valid ASCII
[Success] Valid 2 Octet Sequence
[Success] Invalid 2 Octet Sequence
[Success] Invalid Sequence Identifier
[Success] Valid 3 Octet Sequence
[Success] Invalid 3 Octet Sequence (in 2nd Octet)
[Success] Invalid 3 Octet Sequence (in 3rd Octet)
[Success] Valid 4 Octet Sequence
[Success] Invalid 4 Octet Sequence (in 2nd Octet)
[Success] Invalid 4 Octet Sequence (in 3rd Octet)
[Success] Invalid 4 Octet Sequence (in 4th Octet)
[Fail] Valid 5 Octet Sequence (but not Unicode!)
[Fail] Valid 6 Octet Sequence (but not Unicode!)
- Output for 4.4.3 - 4.4.4, 5.1.3 - 5.1.6, 5.2.0
- Checking with PCRE u modifier
[Success] Valid ASCII
[Success] Valid 2 Octet Sequence
[Success] Invalid 2 Octet Sequence
[Success] Invalid Sequence Identifier
[Success] Valid 3 Octet Sequence
[Success] Invalid 3 Octet Sequence (in 2nd Octet)
[Success] Invalid 3 Octet Sequence (in 3rd Octet)
[Success] Valid 4 Octet Sequence
[Success] Invalid 4 Octet Sequence (in 2nd Octet)
[Success] Invalid 4 Octet Sequence (in 3rd Octet)
[Success] Invalid 4 Octet Sequence (in 4th Octet)
[Fail] Valid 5 Octet Sequence (but not Unicode!)
[Fail] Valid 6 Octet Sequence (but not Unicode!)
Checking with mb_check_encoding
[Success] Valid ASCII
[Success] Valid 2 Octet Sequence
[Fail] Invalid 2 Octet Sequence
[Fail] Invalid Sequence Identifier
[Success] Valid 3 Octet Sequence
[Fail] Invalid 3 Octet Sequence (in 2nd Octet)
[Fail] Invalid 3 Octet Sequence (in 3rd Octet)
[Success] Valid 4 Octet Sequence
[Fail] Invalid 4 Octet Sequence (in 2nd Octet)
[Fail] Invalid 4 Octet Sequence (in 3rd Octet)
[Fail] Invalid 4 Octet Sequence (in 4th Octet)
[Fail] Valid 5 Octet Sequence (but not Unicode!)
[Fail] Valid 6 Octet Sequence (but not Unicode!)
- Output for 5.0.0 - 5.0.5, 5.1.0 - 5.1.2
- Checking with PCRE u modifier
[Success] Valid ASCII
[Success] Valid 2 Octet Sequence
[Success] Invalid 2 Octet Sequence
[Success] Invalid Sequence Identifier
[Success] Valid 3 Octet Sequence
[Success] Invalid 3 Octet Sequence (in 2nd Octet)
[Success] Invalid 3 Octet Sequence (in 3rd Octet)
[Success] Valid 4 Octet Sequence
[Success] Invalid 4 Octet Sequence (in 2nd Octet)
[Success] Invalid 4 Octet Sequence (in 3rd Octet)
[Success] Invalid 4 Octet Sequence (in 4th Octet)
[Fail] Valid 5 Octet Sequence (but not Unicode!)
[Fail] Valid 6 Octet Sequence (but not Unicode!)
Checking with mb_check_encoding
Fatal error: Call to undefined function mb_check_encoding() in /in/oP3Ve on line 21
Process exited with code 255. - Output for 4.3.5 - 4.3.11, 4.4.0 - 4.4.2
- Checking with PCRE u modifier
[Success] Valid ASCII
[Success] Valid 2 Octet Sequence
[Success] Invalid 2 Octet Sequence
[Success] Invalid Sequence Identifier
[Success] Valid 3 Octet Sequence
[Success] Invalid 3 Octet Sequence (in 2nd Octet)
[Success] Invalid 3 Octet Sequence (in 3rd Octet)
[Success] Valid 4 Octet Sequence
[Success] Invalid 4 Octet Sequence (in 2nd Octet)
[Success] Invalid 4 Octet Sequence (in 3rd Octet)
[Success] Invalid 4 Octet Sequence (in 4th Octet)
[Fail] Valid 5 Octet Sequence (but not Unicode!)
[Fail] Valid 6 Octet Sequence (but not Unicode!)
Checking with mb_check_encoding
Fatal error: Call to undefined function: mb_check_encoding() in /in/oP3Ve on line 21
Process exited with code 255. - Output for 4.3.2 - 4.3.4
- Checking with PCRE u modifier
[Success] Valid ASCII
[Success] Valid 2 Octet Sequence
[Fail] Invalid 2 Octet Sequence
[Fail] Invalid Sequence Identifier
[Success] Valid 3 Octet Sequence
[Fail] Invalid 3 Octet Sequence (in 2nd Octet)
[Fail] Invalid 3 Octet Sequence (in 3rd Octet)
[Success] Valid 4 Octet Sequence
[Fail] Invalid 4 Octet Sequence (in 2nd Octet)
[Fail] Invalid 4 Octet Sequence (in 3rd Octet)
[Fail] Invalid 4 Octet Sequence (in 4th Octet)
[Fail] Valid 5 Octet Sequence (but not Unicode!)
[Fail] Valid 6 Octet Sequence (but not Unicode!)
Checking with mb_check_encoding
Fatal error: Call to undefined function: mb_check_encoding() in /in/oP3Ve on line 21
Process exited with code 255. - Output for 4.3.0 - 4.3.1
- Checking with PCRE u modifier
[Success] Valid ASCII
[Success] Valid 2 Octet Sequence
[Fail] Invalid 2 Octet Sequence
[Fail] Invalid Sequence Identifier
[Success] Valid 3 Octet Sequence
[Fail] Invalid 3 Octet Sequence (in 2nd Octet)
[Fail] Invalid 3 Octet Sequence (in 3rd Octet)
[Success] Valid 4 Octet Sequence
[Fail] Invalid 4 Octet Sequence (in 2nd Octet)
[Fail] Invalid 4 Octet Sequence (in 3rd Octet)
[Fail] Invalid 4 Octet Sequence (in 4th Octet)
[Fail] Valid 5 Octet Sequence (but not Unicode!)
[Fail] Valid 6 Octet Sequence (but not Unicode!)
Checking with mb_check_encoding
Fatal error: Call to undefined function: mb_check_encoding() in /in/oP3Ve on line 21
preferences:
298.44 ms | 402 KiB | 359 Q