Req #38316 [Opn->Csd]: html_entity_decode() unexpected results

From: Date: Sun, 13 Jul 2014 01:01:22 +0000
Subject: Req #38316 [Opn->Csd]: html_entity_decode() unexpected results
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186582@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=38316&edit=1 ID: 38316 Updated by: yohgaki@php.net Reported by: raymond at rnamusic dot com Summary: html_entity_decode() unexpected results -Status: Open +Status: Closed Type: Feature/Change Request -Package: Feature/Change Request +Package: *General Issues Operating System: Linux PHP Version: 4.4.3 -Assigned To: +Assigned To: yohgaki Block user comment: N Private report: N New Comment: I think this could be closed. Please re-open if you still have similar issue. Previous Comments: ------------------------------------------------------------------------ [2011-10-06 05:23:22] reg dot php at alf dot nu The documentation (well, the signature at the top) claims the third argument defaults to UTF-8, this is wrong. You want html_entity_decode($string, ENT_QUOTES, 'UTF-8') ------------------------------------------------------------------------ [2006-08-03 16:28:33] raymond at rnamusic dot com not your bug submission script translates my example ascii char into an entity, so where you read "e&#769;" should be a sigle ascii character. fyi. ------------------------------------------------------------------------ [2006-08-03 16:27:00] raymond at rnamusic dot com Description: ------------ In all example code, and in all php functions, I can not find a simple snipet that will find html enties that are attached to characters (e.g. "e&#x301;" a unicode construct) and decode them properly (to "e&#769;"). The string "Japrisot, Se&#x301;bastien" is just ignored by html_entity_decode() and returned as is -- nothing changed. The only solution seems to write a custom replacement function, which seems a bit odd since html_entity_decode purports to decode common entities. If you work with marc records, as I do you come across these entities all the time. Reproduce code: --------------- <?php $string = "Japrisot, Se&#x301;bastien"; $decoded = html_entity_decode($string); echo $decoded; ?> Expected result: ---------------- Japrisot, Se&#769;bastien Actual result: -------------- Japrisot, Se&#x301;bastien ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=38316&edit=1

« previous php.bugs (#186582) next »