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