本文介绍了PHP解码GB2312的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理IMAP电子邮件脚本,并且我在(我假设是中文编码),看起来像这样 =?GB2312?B?foobarbazetc
I'm working on an IMAP email script and I have some lines coded in GB2312 (which I assume is Chinese encoding), looks like this =?GB2312?B?foobarbazetc
使用这个字符串?我检查了 mb_list_encodings()
,这个没有列出。
How can I start working with this string? I checked mb_list_encodings()
and this one is not listed.
推荐答案
如果您有base64解码的数据,则使用mbstring或iconv。
If you have the base64-decoded data, then use mbstring or iconv. If you have the raw header, then mbstring.
<?php
$t = "\xc4\xe3\xba\xc3\n";
echo iconv('GB2312', 'UTF-8', $t);
echo mb_convert_encoding($t, 'UTF-8', 'GB2312');
mb_internal_encoding('UTF-8');
echo mb_decode_mimeheader("=?gb2312?b?xOO6ww==?=");
?>
这篇关于PHP解码GB2312的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!