note 92497 modified in function.utf8-decode by danbrown
| From: | danbrown@php.net | Date: | Mon, 27 Jul 2009 14:59:23 +0000 |
| Subject: | note 92497 modified in function.utf8-decode by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-158780@lists.php.net to get a copy of this message | ||
If you simply need to decode a previously numerically escaped string (for example "This is
\xC3encoded\xAF - now what?") into its literal (unencoded) representation:
<?php
preg_replace("#(\\\x[0-9A-F]{2})#e", "chr(hexdec('\\1'))", $string);
?>
PS: note the miraculous escaping of \x in the regex as \\\x (!)
--was--
If you simply need to decode a previously numerically escaped string (for example "This is
\xC3encoded\xAF - now what?") into its literal (unencoded) representation:
preg_replace("#(\\\x[0-9A-F]{2})#e", "chr(hexdec('\\1'))", $string);
PS: note the miraculous escaping of \x in the regex as \\\x (!)
http://php.net/manual/en/function.utf8-decode.php