【问题标题】:PHP HTML DecodePHP HTML 解码
【发布时间】:2014-11-07 23:43:03
【问题描述】:

我不得不使用如下所示的 HTML:

<font color=3D=22=236EAED2=22 style=3D=22font-siz=
e:13px;font-family:arial;=22><B>Some Info Here</B></font></=
A></td></tr><tr><td><font color=3D=22=23FFFFFF=22 style=3D=22font-size:11=
px;font-family:arial;=22>192 Wellington Parade =7C Melbourne =7C  VIC =7C=
Australia 3002</font></td></tr><tr><td><font color=3D=22=23FFFFFF=22 st=
yle=3D=22font-size:11px;font-family:arial;=22>T: 61-<a href=3D=22=23=22 s=
tyle=3D=22color:=23FFFFFF; text-decoration:none=22>

看起来 " 被转换为 =22 等等。 还有其他“代码”,例如 =7C =3D、= 在每个新行之前等等。

&nbsp; is =26nbsp;

是否有任何功能或技术可以恢复到正确的 HTML?

谢谢。

【问题讨论】:

  • 这不属于 PHP 部分。
  • 可以的,你可以用str_replace来做一些修改。
  • 是的,你也可以使用 preg_replace 不是重点。我认为php在这里是不可能的。
  • 不是真的@Daan - Quoted Printable Decode

标签: php html encoding character-encoding


【解决方案1】:

使用quoted_printable_decode("YOUR String to decode");imap_qprint("Your String to decode")

检查FIDDLE

说明:quoted_printable_decode — 将带引号的可打印字符串转换为 8 位字符串

他的函数返回一个 8 位二进制字符串,对应于解码后的带引号的可打印字符串(根据 » RFC2045,第 6.7 节,而不是 » RFC2821,第 4.5.2 节,因此不会从行首删除额外的句点)。

More Infohere too

【讨论】:

  • 非常感谢你们! quote_printable_decode() 完美地解决了它,我不知道那个功能,@Gumbo 你的回答也很有帮助,谢谢。
  • @tonirmc,欢迎。两者都相同,但 imap_qprint() :这个需要 IMAP 模块/扩展才能工作。
【解决方案2】:

那是quoted-printable encoding,可以用quoted_printable_decode解码。

像这样:

$input= "the string that you need to be decoded";
$output = quoted_printable_decode($input);
echo $output;

【讨论】:

  • 链接易腐烂,您应该在答案中包含一些代码;)
  • @AresDraguna 喜欢$output = quoted_printable_decode($input) 还是什么?
  • 是的,完全一样 ;) 再一次,链接是易腐烂的
【解决方案3】:

看起来他们只是简单地将“%”替换为 =。你说 =22 被翻译成 '"',而 %22 是 "." 的 url 编码字符。

看看here for a chart,你可能会想办法用PHP 替换字符。

另外,quotedprintablehtmlspecialchars 可能会有一些用处

【讨论】:

    猜你喜欢
    • 2011-05-18
    • 2011-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-27
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多