PHP \ uXXXX encoded string converted to utf-8

I have such lines

\u041d\u0418\u041a\u041e\u041b\u0410\u0415\u0412 

How can I convert this to utf-8 encoding? And what is the encoding of this string? Thanks for participating!

+4
source share
2 answers

A simple approach would be to turn your string into double quotes and let json_decode convert the escape strings \u0000 . (Which is Javascript string syntax.)

  $str = json_decode("\"$str\""); 

These seem to be Russian letters: (This is already UTF-8 when json_decode returns it.)

+8
source

To parse this string in PHP, you can use json_decode because JSON supports this unicode literal.

+1
source

All Articles