1--TEST-- 2iconv_mime_decode() 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 9function my_error_handler($errno, $errmsg, $filename, $linenum, $vars) 10{ 11 echo "$errno: $errmsg\n"; 12} 13set_error_handler('my_error_handler'); 14 15function 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 23function do_regression_test() 24{ 25 do_single_test(<<< HERE 26Subject: =?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?= 29HERE 30); 31 do_single_test(<<< HERE 32Subject: =?ISO-8859-1?Q?Pr=FCfung?= =?ISO-8859-1*de_DE?Q?=20Pr=FCfung?= \t =?ISO-8859-2?Q?k=F9=D4=F1=D3let?= 33HERE 34); 35 do_single_test(<<< HERE 36Subject: =?ISO-8859-1?Q?Pr=FCfung?==?ISO-8859-1*de_DE?Q?Pr=FCfung?==?ISO-8859-2?Q?k=F9=D4=F1=D3let?= 37HERE 38); 39 do_single_test(<<< HERE 40Subject: =?ISO-8859-1?Q?Pr=FCfung?= =?ISO-8859-1*de_DE?Q?Pr=FCfung?? =?ISO-8859-2?X?k=F9=D4=F1=D3let?= 41HERE 42); 43 do_single_test(<<< HERE 44From: =?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==?= 55HERE 56); 57} 58 59$mode = 0; 60do_regression_test(); 61$mode = ICONV_MIME_DECODE_STRICT; 62do_regression_test(); 63$mode = ICONV_MIME_DECODE_CONTINUE_ON_ERROR; 64do_regression_test(); 65$mode = ICONV_MIME_DECODE_STRICT | ICONV_MIME_DECODE_CONTINUE_ON_ERROR; 66do_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" 712: 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?=" 772: 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 91