php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #52006 Misleading Documentation on iconv_mime_encode()
Submitted: 2010-06-06 12:34 UTC Modified: 2010-10-24 16:02 UTC
Votes:8
Avg. Score:4.6 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: alix dot axel at gmail dot com Assigned: kalle (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.1 OS: Windows 7
Private report: No CVE-ID: None
 [2010-06-06 12:34 UTC] 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?=

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-06 12:38 UTC] alix dot axel at gmail dot com
-PHP Version: 5.2.13 +PHP Version: 5.3.1
 [2010-06-06 12:38 UTC] alix dot axel at gmail dot com
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'.
 [2010-10-22 15:46 UTC] kalle@php.net
-Package: ICONV related +Package: Documentation problem
 [2010-10-24 16:02 UTC] kalle@php.net
Automatic comment from SVN on behalf of kalle
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=304699
Log: Fixed bug #52006 (Misleading Documentation on iconv_mime_encode())
 [2010-10-24 16:02 UTC] kalle@php.net
-Status: Open +Status: Closed -Assigned To: +Assigned To: kalle
 [2010-10-24 16:02 UTC] kalle@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-02-07 06:08 UTC] phpdocbot@php.net
Automatic comment on behalf of kalle
Revision: http://git.php.net/?p=doc/en.git;a=commit;h=50f157563de05cf7e9a568b8cf8b0f5897a3eed6
Log: Fixed bug #52006 (Misleading Documentation on iconv_mime_encode())
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 18:00:02 2026 UTC