1--TEST-- 2iconv stream filter 3--SKIPIF-- 4<?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?> 5--INI-- 6iconv.internal_charset=iso-8859-1 7--FILE-- 8<?php 9$fp = fopen(dirname(__FILE__).'/iconv_stream_filter.txt', 'rb'); 10var_dump(bin2hex(fread($fp, 10))); 11var_dump(bin2hex(fread($fp, 5))); 12var_dump(bin2hex(fread($fp, 1))); 13fclose($fp); 14 15$fp = fopen(dirname(__FILE__).'/iconv_stream_filter.txt', 'rb'); 16stream_filter_append($fp, 'convert.iconv.ISO-2022-JP/EUC-JP'); 17var_dump(bin2hex(fread($fp, 10))); 18var_dump(bin2hex(fread($fp, 5))); 19var_dump(bin2hex(fread($fp, 1))); 20fclose($fp); 21 22$fp = fopen(dirname(__FILE__).'/iconv_stream_filter.txt', 'rb'); 23stream_filter_append($fp, 'string.rot13'); // this will make conversion fail. 24stream_filter_append($fp, 'convert.iconv.ISO-2022-JP/EUC-JP'); 25var_dump(bin2hex(@fread($fp, 10)) != "a4b3a4f3a4cba4c1a4cf"); 26var_dump(bin2hex(fread($fp, 5)) != "69636f6e76"); 27var_dump(bin2hex(fread($fp, 1)) != "0a"); 28fclose($fp); 29?> 30--EXPECT-- 31string(20) "1b244224332473244b24" 32string(10) "41244f1b28" 33string(2) "42" 34string(20) "a4b3a4f3a4cba4c1a4cf" 35string(10) "69636f6e76" 36string(2) "0a" 37bool(true) 38bool(true) 39bool(true) 40