Bug #63806 [Opn->Nab]: html_entity_decode($x, ENT_QUOTES, "UTF-8") doesn't work as advertised wrt. "'"
| From: | rasmus@php.net | Date: | Wed, 19 Dec 2012 19:51:12 +0000 |
| Subject: | Bug #63806 [Opn->Nab]: html_entity_decode($x, ENT_QUOTES, "UTF-8") doesn't work as advertised wrt. "'" | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-175471@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=63806&edit=1
ID: 63806
Updated by: rasmus@php.net
Reported by: t dot glaser at tarent dot de
Summary: html_entity_decode($x, ENT_QUOTES, "UTF-8") doesn't
work as advertised wrt. "'"
-Status: Open
+Status: Not a bug
Type: Bug
Package: Strings related
Operating System: Debian experimental to get 5.4.9
PHP Version: 5.4.9
Block user comment: N
Private report: N
New Comment:
This is not a bug. html_entity_decode() defaults to HTML4 entities. ' is not
a valid HTML4 entity. If you try your code with ' you will see ENT_QUOTES
includes single quotes just fine.
As of PHP 5.4 html_entity_decode() supports both XHTML and HTML5 entities. Use
ENT_QUOTES|ENT_XHTML or ENT_QUOTES|ENT_HTML5 and you will see ' is converted
as you would expect.
Previous Comments:
------------------------------------------------------------------------
[2012-12-19 14:31:08] t dot glaser at tarent dot de
Description:
------------
http://de3.php.net/manual/en/function.html-entity-decode.php
says:
Available flags constants
Constant Name Description
ENT_COMPAT Will convert double-quotes and leave single-quotes alone.
ENT_QUOTES Will convert both double and single quotes.
ENT_NOQUOTES Will leave both double and single quotes unconverted.
ENT_HTML401 Handle code as HTML 4.01.
ENT_XML1 Handle code as XML 1.
ENT_XHTML Handle code as XHTML.
ENT_HTML5 Handle code as HTML 5.
However, I donât see ' being decoded with ENT_QUOTES.
Test script:
---------------
<?php
$x = "'";
$y = html_entity_decode($x, ENT_QUOTES, "UTF-8");
echo "< $y >\n";
Expected result:
----------------
< ' >
Actual result:
--------------
< ' >
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=63806&edit=1