1--TEST-- 2Test iconv_substr() function : basic functionality 3--EXTENSIONS-- 4iconv 5--INI-- 6input_encoding=ISO-8859-1 7internal_encoding=ISO-8859-1 8output_encoding=ISO-8859-1 9--FILE-- 10<?php 11/* 12 * Test Basic Functionality of iconv_substr with ASCII characters and multibyte strings. 13 */ 14 15echo "*** Testing iconv_substr() : basic functionality ***\n"; 16 17$string_ascii = 'ABCDEF'; 18//Japanese string in UTF-8 19$string_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII='); 20 21echo "\n-- ASCII string 1 --\n"; 22var_dump(bin2hex(iconv_substr($string_ascii, 3))); 23 24echo "\n-- ASCII string 2 --\n"; 25var_dump(bin2hex(iconv_substr($string_ascii, 3, 5, 'ISO-8859-1'))); 26 27echo "\n-- Multibyte string 1 --\n"; 28$result_1 = iconv_substr($string_mb, 2, 7); 29var_dump(bin2hex($result_1)); 30 31echo "\n-- Multibyte string 2 --\n"; 32$result_2 = iconv_substr($string_mb, 2, 7, 'utf-8'); 33var_dump(bin2hex($result_2)); 34 35echo "Done"; 36?> 37--EXPECT-- 38*** Testing iconv_substr() : basic functionality *** 39 40-- ASCII string 1 -- 41string(6) "444546" 42 43-- ASCII string 2 -- 44string(6) "444546" 45 46-- Multibyte string 1 -- 47string(14) "a5e69cace8aa9e" 48 49-- Multibyte string 2 -- 50string(42) "e8aa9ee38386e382ade382b9e38388e381a7e38199" 51Done 52