[PEAR-BUG] Bug #18746 [Opn->Bgs]: Headers are decoded incorrectly

[email protected]
Newsgroups php.pear.bugs
Message-ID <[email protected]>
Edit report at http://pear.php.net/bugs/bug.php?id=18746&edit=1

 ID:               18746
 Updated by:       [email protected]
 Reported By:      d dot travnikov at gmail dot com
 Summary:          Headers are decoded incorrectly
-Status:           Open
+Status:           Bogus
 Type:             Bug
 Package:          Mail_mimeDecode
 Operating System: FreeBSD
 Package Version:  1.5.5
 PHP Version:      5.3.6
 Roadmap Versions: 
 New Comment:

-Status: Open
+Status: Bogus
Thank you for taking the time to write to us, but this is not
a bug.

json_encode will only encode UTF8 - you need to convert the string to
unicode before outputing.


Previous Comments:
------------------------------------------------------------------------

[2011-08-20 17:40:43] karabas

Description:
------------
Let's say, the script should get the letter and return decoded 
subject in JSON. If, for example, subject to be encoded in koi8-r, 
then json_encode of decoded string will return null, because in 
the decoded string contains illegal utf-8 codes.

Here is an example: =?koi8-r?B?4dPUxdLPycTZ?=


Test script:
---------------
<?php
require_once dirname(__FILE__) . '/mimeDecode.php';
$params['decode_headers'] = true;
$decoder = new Mail_mimeDecode('Subject: =?koi8-r?B?4dPUxdLPycTZ?=');
$struct = $decoder->decode($params);
print json_encode($struct->headers['subject']);


Expected result:
----------------
"\u0410\u0441\u0442\u0435\u0440\u043e\u0438\u0434\u044b"

Actual result:
--------------
null

------------------------------------------------------------------------


-- 
Edit this bug report at http://pear.php.net/bugs/bug.php?id=18746&edit=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.