Skip to content

Instantly share code, notes, and snippets.

@youkidearitai
Last active January 30, 2023 17:23
Show Gist options
  • Save youkidearitai/0965634060e714c1b2f6439f2ec08fe1 to your computer and use it in GitHub Desktop.
Save youkidearitai/0965634060e714c1b2f6439f2ec08fe1 to your computer and use it in GitHub Desktop.
--TEST--
Check that strings are marked as not valid UTF-8 (ISO-2022-JP)
--EXTENSIONS--
zend_test
--FILE--
<?php
echo "ISO-2022-JP String:\n";
$a = "a";
$esc1 = "\x1b";
$esc2 = "\x24";
$esc3 = "\x42";
$esc = $esc1 . $esc2 . $esc3;
$b = "\x24";
$b .= "\x22";
$esc_b = $esc . $b; // 0x24 0x22 "あ"
var_dump(zend_test_is_string_marked_as_valid_utf8($a));
var_dump(zend_test_is_string_marked_as_valid_utf8($b));
var_dump(zend_test_is_string_marked_as_valid_utf8($esc));
var_dump(zend_test_is_string_marked_as_valid_utf8($esc_b));
?>
--EXPECT--
ISO-2022-JP String:
bool(true)
bool(true)
bool(true)
bool(true)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment