#50153 [Opn->Fbk]: mb_convert_encoding couldn't convert GB2312 to UTF8 well?

From: Date: Thu, 12 Nov 2009 08:46:54 +0000
Subject: #50153 [Opn->Fbk]: mb_convert_encoding couldn't convert GB2312 to UTF8 well?
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-144517@lists.php.net to get a copy of this message
 ID:               50153
 Updated by:       jani@php.net
 Reported By:      kiange at gmail dot com
-Status:           Open
+Status:           Feedback
 Bug Type:         mbstring related
 Operating System: Ubuntu 9.04
-PHP Version:      5.2.11
+PHP Version:      5.2.6
 New Comment:

Please try using this snapshot:

  http://snaps.php.net/php5.2-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/




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

[2009-11-12 02:59:14] kiange at gmail dot com

Description:
------------
A mail message fetched from gmail. The original message encoded in 
big5, but the result come from gmail become GB2312 in attachments' 
name. And when converting it into utf8 with mb_convert_encoding(), the

result become unreadable. But when change GB2312 to GBK, the result 
becomes better. Although I'm not sure if it still correct in 
characters' code, but I could read it.

Hope you won't mind that I only tested it in PHP 5.2.6.

Reproduce code:
---------------
<?php
$encodedString =
'=?GB2312?B?MjAwOTExMDZfQ1lDVU1JU0xhYl+5UNObX5pXwM+On9Ob5JsuZG9j?=';
$imapDecode = imap_mime_header_decode($string);
// Returning unreadable result
mb_convert_encoding($imapDecode[0]->text, 'UTF-8', 'GB2312');
// Returning correct result
mb_convert_encoding($imapDecode[0]->text, 'UTF-8', 'GBK');



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


-- 
Edit this bug report at http://bugs.php.net/?id=50153&edit=1



Thread (2 messages)

« previous php.bugs (#144517) next »