]> granicus.if.org Git - php/commitdiff
- MFH:Add a new test for the additional delimiter of the encoding conversion
authorMoriyoshi Koizumi <moriyoshi@php.net>
Thu, 14 May 2009 19:07:41 +0000 (19:07 +0000)
committerMoriyoshi Koizumi <moriyoshi@php.net>
Thu, 14 May 2009 19:07:41 +0000 (19:07 +0000)
  filter

ext/iconv/tests/iconv_stream_filter_delimiter.phpt [new file with mode: 0644]

diff --git a/ext/iconv/tests/iconv_stream_filter_delimiter.phpt b/ext/iconv/tests/iconv_stream_filter_delimiter.phpt
new file mode 100644 (file)
index 0000000..e28ebab
--- /dev/null
@@ -0,0 +1,50 @@
+--TEST--
+iconv stream filter
+--SKIPIF--
+<?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
+--INI--
+iconv.internal_charset=iso-8859-1
+--FILE--
+<?php
+$fp = fopen(dirname(__FILE__).'/iconv_stream_filter.txt', 'rb');
+var_dump(bin2hex(fread($fp, 10)));
+var_dump(bin2hex(fread($fp, 5)));
+var_dump(bin2hex(fread($fp, 1)));
+fclose($fp);
+
+$fp = fopen(dirname(__FILE__).'/iconv_stream_filter.txt', 'rb');
+stream_filter_append($fp, 'convert.iconv.ISO-2022-JP/EUC-JP');
+var_dump(bin2hex(fread($fp, 10)));
+var_dump(bin2hex(fread($fp, 5)));
+var_dump(bin2hex(fread($fp, 1)));
+fclose($fp);
+
+$fp = fopen(dirname(__FILE__).'/iconv_stream_filter.txt', 'rb');
+stream_filter_append($fp, 'convert.iconv.ISO-2022-JP.EUC-JP');
+var_dump(bin2hex(fread($fp, 10)));
+var_dump(bin2hex(fread($fp, 5)));
+var_dump(bin2hex(fread($fp, 1)));
+fclose($fp);
+
+$fp = fopen(dirname(__FILE__).'/iconv_stream_filter.txt', 'rb');
+stream_filter_append($fp, 'convert.iconv.ISO-2022-JP\0EUC-JP');
+var_dump(bin2hex(fread($fp, 10)));
+var_dump(bin2hex(fread($fp, 5)));
+var_dump(bin2hex(fread($fp, 1)));
+fclose($fp);
+?>
+--EXPECTF--
+string(20) "1b244224332473244b24"
+string(10) "41244f1b28"
+string(2) "42"
+string(20) "a4b3a4f3a4cba4c1a4cf"
+string(10) "69636f6e76"
+string(2) "0a"
+string(20) "a4b3a4f3a4cba4c1a4cf"
+string(10) "69636f6e76"
+string(2) "0a"
+
+Warning: stream_filter_append(): unable to create or locate filter "convert.iconv.ISO-2022-JP\0EUC-JP" in %s/iconv_stream_filter_delimiter.php on line %d
+string(20) "1b244224332473244b24"
+string(10) "41244f1b28"
+string(2) "42"