note 31815 deleted from function.utf8-decode by cmb
| From: | cmb@php.net | Date: | Sun, 11 Dec 2016 11:33:56 +0000 |
| Subject: | note 31815 deleted from function.utf8-decode by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208534@lists.php.net to get a copy of this message | ||
Note Submitter: johan dot andersson at strateg dot se
----
A simple way to convert utf-8 encoded strings...
(PHP 4 >= 4.3.0)
<?php
$newstring = html_entity_decode(htmlentities($utf8_string, ENT_COMPAT, 'UTF-8'));
?>
(For 4.1.0 >= PHP < 4.3.0 use this function instead of html_entity_decode)
<?php
function unhtmlentities ($string)
{
$trans_tbl = get_html_translation_table (HTML_ENTITIES);
$trans_tbl = array_flip ($trans_tbl);
return strtr ($string, $trans_tbl);
}
$newstring = unhtmlentities(htmlentities($utf8_string, ENT_COMPAT, 'UTF-8'));
?>
//Johan