0

When I use json_encode('тест') I get this result \u0422\u0435\u0441\u0442 But if you pass ascii characters, then it will stop working echo json_encode('test'); #test How can I fix this to get such a code \u0074\u0065\u0073\u0074?

Alex Filatov
  • 17
  • 1
  • 2
  • Why do you want to encode even ASCII to Unicode escape sequences? There isn't a whole lot of sense in doing that. `json_encode` chooses Unicode escape sequences for non-ASCII characters so the result is pure ASCII and you don't need to worry about text encodings. But encoding ASCII characters as other ASCII character sequences doesn't bring any benefit and only makes the result five times longer and harder to read. – deceze Mar 31 '20 at 10:22
  • Yes, I understand that, but this is a feature of the project. – Alex Filatov Mar 31 '20 at 10:39
  • You'll need to do that manually then. I've added a few duplicates for that. – deceze Mar 31 '20 at 10:41

0 Answers0