Skip to content

Instantly share code, notes, and snippets.

@warmwinter
Forked from aeurielesn/util.php
Created March 11, 2016 08:08
Show Gist options
  • Save warmwinter/4dea1a25802e8fe7232d to your computer and use it in GitHub Desktop.
Save warmwinter/4dea1a25802e8fe7232d to your computer and use it in GitHub Desktop.

Revisions

  1. @aeurielesn aeurielesn renamed this gist Jul 31, 2011. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.aw → util.php
    Original file line number Diff line number Diff line change
    @@ -9,4 +9,6 @@ function unicode_decode($str) {
    return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $str);
    }

    $str = unicode_decode('\u00e9');

    ?>
  2. @aeurielesn aeurielesn revised this gist Jul 31, 2011. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,6 @@
    <?php
    #source: http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-char

    function replace_unicode_escape_sequence($match) {
    return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
    }
    @@ -6,5 +9,4 @@ function unicode_decode($str) {
    return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $str);
    }


    #source: http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-char
    ?>
  3. @aeurielesn aeurielesn created this gist Jul 31, 2011.
    10 changes: 10 additions & 0 deletions gistfile1.aw
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    function replace_unicode_escape_sequence($match) {
    return mb_convert_encoding(pack('H*', $match[1]), 'UTF-8', 'UCS-2BE');
    }

    function unicode_decode($str) {
    return preg_replace_callback('/\\\\u([0-9a-f]{4})/i', 'replace_unicode_escape_sequence', $str);
    }


    #source: http://stackoverflow.com/questions/2934563/how-to-decode-unicode-escape-sequences-like-u00ed-to-proper-utf-8-encoded-char