Search code examples
phpemojidecoding

Decoding emoji: it has a strange format I can't find elsewhere


This is the string I got:

%uD83D%uDE0C

I'm pretty sure it is an emoji, but when I try to decode it with this library: https://github.com/BriquzStudio/php-emoji, it does not work.

I also tried that library with php's urldecode function but with no luck.

Can somebody tell me what kind of decoding this is and/or how I can decode this?


Solution

  • Because the encoding appears to be non-standard, I recommend this:

    $string = "%uD83D%uDE0C";
    echo json_decode('"' . str_replace('%','\\',$string) . '"');
    

    What it does is converts "%uD83D%uDE0C" to "\uD83D\uDE0C", which is a valid javascript encoding. Then it uses json_decode to interpret the javascript.