百科狗-知识改变命运!

iconv_mime_decode() - iconv函数(字符编码转换库)

乐乐2年前 (2023-11-21)阅读数 27#技术干货
文章标签字段

iconv_mime_decode()

(PHP 5, PHP 7)

解码一个MIME头字段

说明

iconv_mime_decode(string $encoded_header[,int $mode= 0[,string $charset= ini_get("iconv.internal_encoding")]]): string

解码一个MIME头字段.

参数

$encoded_header

编码头,是一个字符串.

$mode

模式决定了当iconv_mime_decode()遇到一个不规则的MIME头字段时,对这个事件作出的行为.你可以指定以下位掩码的任意组合.

iconv_mime_decode() - iconv函数(字符编码转换库)

可以在iconv_mime_decode()中使用的位掩码
常量描述
1ICONV_MIME_DECODE_STRICT如果使用该位掩码,传入的头字段将会完全一致的按照» RFC2047的标准定义被解码.这个选项默认是禁用的,因为有很多零散的邮件用户代理商不遵守标准规范并且不生成正确的MIME头.
2ICONV_MIME_DECODE_CONTINUE_ON_ERROR如果使用该位掩码,iconv_mime_decode_headers()将会试图忽略任何错误语法,并继续处理传入的头字段.
$charset

可选的字符集参数,用指定的字符集表示结果.如果省略,iconv.internal_encoding将会被默认使用.

返回值

如果解码成功,返回一个被解码的MIME字段,如果在解码过程中出现一个错误,将返回FALSE.

范例

iconv_mime_decode()实例


参见

  • iconv_mime_decode_headers()一次性解码多个 MIME 头字段
  • mb_decode_mimeheader()解码 MIME 头字段中的字符串
  • imap_mime_header_decode()Decode MIME header elements
  • imap_base64()Decode BASE64 encoded text
  • imap_qprint()Convert a quoted-printable string to an 8 bit string
While creating a new webmailer, I had to coop with a lot of mails and only half of them were correct encoded!
Often the text is tagged as ISO but in real its UTF :/
After trying a lot of solutions and combination a found a way which seems to work for all our mails. Maybe its usefull to someone else too.

In PHP versions that have imap_mime_decode built in, it's possible to emulate the operation of this function:

内容声明:本文中引用的各种信息及资料(包括但不限于文字、数据、图表及超链接等)均来源于该信息及资料的相关主体(包括但不限于公司、媒体、协会等机构)的官方网站或公开发表的信息。部分内容参考包括:(百度百科,百度知道,头条百科,中国民法典,刑法,牛津词典,新华词典,汉语词典,国家院校,科普平台)等数据,内容仅供参考使用,不准确地方联系删除处理!本站为非盈利性质站点,本着为中国教育事业出一份力,发布内容不收取任何费用也不接任何广告!)
{if $zbp->Config('yd1125')->foot}