So the story goes, I'm trying to save a JSON string to my database, but every Hebrew letter is transforming into "\u05d4" for example, which supposed to be the letter "He" in Hebrew (ה).
English is encoded properly
I've done my research and found that this encoding is JAVA or C/C++ character encoding, but I can't find a way to store it in my database as regular UTF-8 character for editing convenience...
Fetching the data and showing it on my pages works well(in Hebrew, as it should) but no matter what functions I try to throw at the problem, the data in my database is encoded...
Example:
\u05d0\u05d9\u05e4\u05d4 \u05ea\u05e8\u05e6\u05d4 \u05e9\u05d4\u05e9\u05dd \u05d9\u05de\u05d5\u05e7\u05dd?
is supposed to be:
איפה תרצה שהשם ימוקם?
As you can see, the encoding also takes up a lot of extra space, and editing from phpMyAdmin is impossible...
my functions to save the data:
mysql_real_escape_string(json_encode($pinfo))
while $pinfo contains all of the data in array(which is encoded in utf-8)
Is it a problem with JSON_ENCODE() or something else completely that I'm not aware of yet?
EDIT
Using the information given by Álvaro González and Tanuel Mategi, I was able to find the solution I was after:
mysql_real_escape_string(json_encode($pinfo, JSON_UNESCAPED_UNICODE))
Hope it helps!
\u05d4
is a perfectly valid escape sequence in JSON. It corresponds to the U+05d4 Unicode character (Hebrew Letter He). There's apparently nothing wrong in your JSON output—I think you just misread the format documentation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With