fork download
  1. <?php
  2.  
  3. function entities_to_unicode($str) {
  4. $str = html_entity_decode($str, ENT_QUOTES, 'UTF-8');
  5. $str = preg_replace_callback("/(&#[0-9]+;)/", function($m) { return mb_convert_encoding($m[1], "UTF-8", "HTML-ENTITIES"); }, $str);
  6. return $str;
  7. }
  8.  
  9. $str = 'Oggi &egrave; un bel&nbsp;giorno';
  10. echo entities_to_unicode($str);
Success #stdin #stdout 0.02s 25860KB
stdin
Standard input is empty
stdout
Oggi è un bel giorno