Annotation of embedaddon/php/ext/iconv/tests/iconv_mime_decode.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: iconv_mime_decode()
! 3: --SKIPIF--
! 4: <?php extension_loaded('iconv') or die('skip iconv extension is not available'); ?>
! 5: --INI--
! 6: iconv.internal_charset=iso-8859-1
! 7: --FILE--
! 8: <?php
! 9: function my_error_handler($errno, $errmsg, $filename, $linenum, $vars)
! 10: {
! 11: echo "$errno: $errmsg\n";
! 12: }
! 13: set_error_handler('my_error_handler');
! 14:
! 15: function do_single_test($header)
! 16: {
! 17: global $mode;
! 18:
! 19: $result = iconv_mime_decode($header, $mode, "UTF-8");
! 20: printf("(%d) \"%s\"\n", iconv_strlen($result, "UTF-8"), $result);
! 21: }
! 22:
! 23: function do_regression_test()
! 24: {
! 25: do_single_test(<<< HERE
! 26: Subject: =?ISO-8859-1?Q?Pr=FCfung?=
! 27: =?ISO-8859-1*de_DE?Q?Pr=FCfung?=\t
! 28: =?ISO-8859-2?Q?k=F9=D4=F1=D3let?=
! 29: HERE
! 30: );
! 31: do_single_test(<<< HERE
! 32: Subject: =?ISO-8859-1?Q?Pr=FCfung?= =?ISO-8859-1*de_DE?Q?=20Pr=FCfung?= \t =?ISO-8859-2?Q?k=F9=D4=F1=D3let?=
! 33: HERE
! 34: );
! 35: do_single_test(<<< HERE
! 36: Subject: =?ISO-8859-1?Q?Pr=FCfung?==?ISO-8859-1*de_DE?Q?Pr=FCfung?==?ISO-8859-2?Q?k=F9=D4=F1=D3let?=
! 37: HERE
! 38: );
! 39: do_single_test(<<< HERE
! 40: Subject: =?ISO-8859-1?Q?Pr=FCfung?= =?ISO-8859-1*de_DE?Q?Pr=FCfung?? =?ISO-8859-2?X?k=F9=D4=F1=D3let?=
! 41: HERE
! 42: );
! 43: do_single_test(<<< HERE
! 44: From: =?ISO-2022-JP?B?GyRCJTUbKEI=?=
! 45: =?ISO-2022-JP?B?GyRCJXMlVxsoQg==?=
! 46: =?ISO-2022-JP?B?GyRCJWtKOBsoQg==?=
! 47: =?ISO-2022-JP?B?GyRCO3pOcxsoQg==?=
! 48: =?ISO-2022-JP?B?GyRCJTUlcxsoQg==?=
! 49: =?ISO-2022-JP?B?GyRCJVclaxsoQg==?=
! 50: =?ISO-2022-JP?B?GyRCSjg7ehsoQg==?=
! 51: =?ISO-2022-JP?B?GyRCTnNGfBsoQg==?=
! 52: =?ISO-2022-JP?B?GyRCS1w4bBsoQg==?=
! 53: =?ISO-2022-JP?B?GyRCJUYlLRsoQg==?=
! 54: =?ISO-2022-JP?B?GyRCJTklSBsoQg==?=
! 55: HERE
! 56: );
! 57: }
! 58:
! 59: $mode = 0;
! 60: do_regression_test();
! 61: $mode = ICONV_MIME_DECODE_STRICT;
! 62: do_regression_test();
! 63: $mode = ICONV_MIME_DECODE_CONTINUE_ON_ERROR;
! 64: do_regression_test();
! 65: $mode = ICONV_MIME_DECODE_STRICT | ICONV_MIME_DECODE_CONTINUE_ON_ERROR;
! 66: do_regression_test();
! 67: --EXPECT--
! 68: (31) "Subject: PrüfungPrüfungkůÔńÓlet"
! 69: (32) "Subject: Prüfung PrüfungkůÔńÓlet"
! 70: (31) "Subject: PrüfungPrüfungkůÔńÓlet"
! 71: 2: iconv_mime_decode(): Malformed string
! 72: (0) ""
! 73: (27) "From: サンプル文字列サンプル文字列日本語テキスト"
! 74: (31) "Subject: PrüfungPrüfungkůÔńÓlet"
! 75: (32) "Subject: Prüfung PrüfungkůÔńÓlet"
! 76: (100) "Subject: =?ISO-8859-1?Q?Pr=FCfung?==?ISO-8859-1*de_DE?Q?Pr=FCfung?==?ISO-8859-2?Q?k=F9=D4=F1=D3let?="
! 77: 2: iconv_mime_decode(): Malformed string
! 78: (0) ""
! 79: (27) "From: サンプル文字列サンプル文字列日本語テキスト"
! 80: (31) "Subject: PrüfungPrüfungkůÔńÓlet"
! 81: (32) "Subject: Prüfung PrüfungkůÔńÓlet"
! 82: (31) "Subject: PrüfungPrüfungkůÔńÓlet"
! 83: (84) "Subject: Prüfung=?ISO-8859-1*de_DE?Q?Pr=FCfung?? =?ISO-8859-2?X?k=F9=D4=F1=D3let?="
! 84: (27) "From: サンプル文字列サンプル文字列日本語テキスト"
! 85: (31) "Subject: PrüfungPrüfungkůÔńÓlet"
! 86: (32) "Subject: Prüfung PrüfungkůÔńÓlet"
! 87: (100) "Subject: =?ISO-8859-1?Q?Pr=FCfung?==?ISO-8859-1*de_DE?Q?Pr=FCfung?==?ISO-8859-2?Q?k=F9=D4=F1=D3let?="
! 88: (84) "Subject: Prüfung=?ISO-8859-1*de_DE?Q?Pr=FCfung?? =?ISO-8859-2?X?k=F9=D4=F1=D3let?="
! 89: (27) "From: サンプル文字列サンプル文字列日本語テキスト"
! 90:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>