fork download
  1. <?php
  2.  
  3. $s = "\xE6\xA0\xBC\xE6\x8B\x89";
  4. echo "Raw: $s\n";
  5.  
  6. $j = preg_replace('/^"(.*)"$/', '$1', json_encode($s));
  7. echo "JSON: $j\n";
  8.  
  9. $e = preg_replace('/\\\\u([0-9a-f]{4})/', '&#$1;', $j);
  10. echo "Entity: $e\n";
  11.  
  12. echo "Synthesis: " . preg_replace('/\\\\u([0-9a-f]{4})/', '&#$1;',
  13. preg_replace('/^"(.*)"$/', '$1', json_encode($s)));
Success #stdin #stdout 0.03s 25708KB
stdin
Standard input is empty
stdout
Raw: 格拉
JSON: \u683c\u62c9
Entity: &#683c;&#62c9;
Synthesis: &#683c;&#62c9;