Skip to content

Commit

Permalink
Add tests for '7bit' and '8bit' text encodings in mbstring
Browse files Browse the repository at this point in the history
  • Loading branch information
alexdowad committed Aug 30, 2021
1 parent 97f8495 commit 34ef8f3
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions ext/mbstring/tests/other_encodings.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
--TEST--
Test of oddball text encodings which are not tested elsewhere
--EXTENSIONS--
mbstring
--SKIPIF--
<?php
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
?>
--FILE--
<?php
mb_substitute_character(0x25);

// "7bit". This is not a real text encoding.
var_dump(mb_convert_encoding("ABC", "7bit", "ASCII"));
var_dump(mb_convert_encoding("\x80", "7bit", "ASCII"));
var_dump(mb_convert_encoding("ABC", "8bit", "7bit"));
echo "7bit done\n";

// "8bit"
var_dump(mb_convert_encoding("\x01\x00", "8bit", "UTF-16BE")); // codepoints over 0xFF are illegal for '8-bit'
echo "8bit done\n";

?>
--EXPECT--
string(3) "ABC"
string(1) "%"
string(3) "ABC"
7bit done
string(1) "%"
8bit done

0 comments on commit 34ef8f3

Please sign in to comment.