PHP:如何解码具有“=20”和“=A0”的字符串
PHP: how to decode a string having "=20" and "=A0"
我正在使用 IMAP API 从 gmail 获取电子邮件。但是有些电子邮件主题编码为
=?utf-8?Q?We=20aren=27t=20fooling=20around=3A=20Up=20to=2050%=20off=20on=20Polo=27s=2C=20Swimwear=2C=20Jeans=20&=20More?=
我不知道它的编码格式和解码方式。实际的电子邮件主题是
We aren't fooling around: Up to 50% off on Polo's, Swimwear, Jeans & More
使用quoted_printable_decode — Convert a quoted-printable string to an 8 bit string函数
$str = "=?utf-8?Q?We=20aren=27t=20fooling=20around=3A=20Up=20to=2050%=20off=20on=20Polo=27s=2C=20Swimwear=2C=20Jeans=20&=20More?=";
echo quoted_printable_decode ( $str );
使用PHP预定义函数
iconv_mime_decode()
<?php
$str = "=?utf-8?Q?We=20aren=27t=20fooling=20around=3A=20Up=20to=2050%=20off=20on=20Polo=27s=2C=20Swimwear=2C=20Jeans=20&=20More?=";
echo iconv_mime_decode($str);
我正在使用 IMAP API 从 gmail 获取电子邮件。但是有些电子邮件主题编码为
=?utf-8?Q?We=20aren=27t=20fooling=20around=3A=20Up=20to=2050%=20off=20on=20Polo=27s=2C=20Swimwear=2C=20Jeans=20&=20More?=
我不知道它的编码格式和解码方式。实际的电子邮件主题是
We aren't fooling around: Up to 50% off on Polo's, Swimwear, Jeans & More
使用quoted_printable_decode — Convert a quoted-printable string to an 8 bit string函数
$str = "=?utf-8?Q?We=20aren=27t=20fooling=20around=3A=20Up=20to=2050%=20off=20on=20Polo=27s=2C=20Swimwear=2C=20Jeans=20&=20More?=";
echo quoted_printable_decode ( $str );
使用PHP预定义函数
iconv_mime_decode()
<?php
$str = "=?utf-8?Q?We=20aren=27t=20fooling=20around=3A=20Up=20to=2050%=20off=20on=20Polo=27s=2C=20Swimwear=2C=20Jeans=20&=20More?=";
echo iconv_mime_decode($str);