Doc #52006 [Opn]: Misleading Documentation on iconv_mime_encode()
| From: | alix dot axel at gmail dot com | Date: | Sun, 06 Jun 2010 10:38:30 +0000 |
| Subject: | Doc #52006 [Opn]: Misleading Documentation on iconv_mime_encode() | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-4507@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=52006&edit=1
ID: 52006
User updated by: alix dot axel at gmail dot com
Reported by: alix dot axel at gmail dot com
Summary: Misleading Documentation on iconv_mime_encode()
Status: Open
Type: Documentation Problem
Package: ICONV related
Operating System: Windows 7
-PHP Version: 5.2.13
+PHP Version: 5.3.1
New Comment:
I should add that my source file is encoded as UTF-8 without BOM, and
all my 'iconv.*_encoding' configuration values are set to 'ISO-8859-1'.
Previous Comments:
------------------------------------------------------------------------
[2010-06-06 12:34:10] alix dot axel at gmail dot com
Description:
------------
I'm using iconv (libiconv) 1.13 with PHP 5.3.1 running under Windows 7
and I've noticed two inconsistencies in calls to iconv_mime_encode() and
the documentation page for that function, I'm not sure if this is due to
errors on the documentations or if the function is buggy:
1) The documentation page states that if 'output-charset' is not passed
with the 'preferences' array it will use the value of 'input-charset'. I
was not able to reproduce this, 'output-charset' seems to default to
'iconv.internal_encoding', even when 'input-charset' is set in the
'preferences' argument.
2) The first example in the documentation page ($preferences["scheme"] =
"Q") doesn't yield the output that the related comment suggests, spaces
are encoded as '=20' and not '_'.
Test script:
---------------
<?php
// 1st inconsistency
echo iconv_get_encoding('internal_encoding') . "\n";
echo iconv_mime_encode('Subject', 'Prüfung Prüfung',
array('scheme' =>
'Q', 'input-charset' => 'UTF-8')) . "\n";
echo iconv_mime_encode('Subject', 'Prüfung Prüfung',
array('scheme' =>
'Q', 'input-charset' => 'UTF-8', 'output-charset' =>
'UTF-8')) . "\n";
// 2nd inconsistency
$preferences = array(
"scheme" => "Q",
"input-charset" => "ISO-8859-1",
"output-charset" => "UTF-8",
"line-length" => 76,
"line-break-chars" => "\n",
);
echo iconv_mime_encode("Subject", "Prüfung Prüfung", $preferences) .
"\n";
?>
Expected result:
----------------
ISO-8859-1
Subject: =?UTF-8?Q?Pr=C3=BCfung=20Pr=C3=BCfung?=
Subject: =?UTF-8?Q?Pr=C3=BCfung=20Pr=C3=BCfung?=
Subject: =?UTF-8?Q?Pr=C3=BCfung_Pr=C3=BCfung?=
Actual result:
--------------
ISO-8859-1
Subject: =?ISO-8859-1?Q?Pr=FCfung=20Pr=FCfung?=
Subject: =?UTF-8?Q?Pr=C3=BCfung=20Pr=C3=BCfung?=
Subject: =?UTF-8?Q?Pr=C3=83=C2=BCfung=20Pr=C3=83=C2=BCfung?=
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=52006&edit=1