I have an older Debian server and a local install of Wordpress; I'm trying to track down why calling:

echo json_encode('😀');

on the Debian server results in "\ud83dde00" but on my local install, calling the same json_encode line results in "\ud83d\ude00" (which is what I'd expect to see on the Debian server too)...

Both versions of php are compiled with mbstring=all enabled, and both use libmbfl version 1.3.2

  • 1
    No PHP versions or distro versions or anything? Apr 18 '18 at 10:28
  • The Debian php is compiled from source (php-5.6.33) using ./configure --prefix=/usr/local/php5.6.33 --disable-all --with-libxml-dir=/usr/include/libxml2/libxml --with-openssl --with-pcre-regex --with-zlib --with-curl --enable-ftp --with-jpeg-dir --with-png-dir --with-xpm-dir --enable-mbstring=all --with-iconv --with-mysql --with-pear --enable-filter --enable-xml --enable-libxml --enable-simplexml --enable-hash --enable-dom --enable-ctype --with-gd=/usr/local so I'm guessing it must be some other older system library that's at fault?
    – jaygooby
    Apr 18 '18 at 10:32
  • I'm not even sure what \ud83dde00 as a value is? Is that UTF16 instead of UTF8?
    – jaygooby
    Apr 18 '18 at 10:33

Facepalm. Because I had --disable-all the json module wasn't being compiled in, so adding --enable-json and recompiling then means that echo json_encode('😀'); now returns "\ud83d\ude00"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.