search

Home  >  Q&A  >  body text

php - After json_encode, the Chinese characters saved in the database become unicode. How is the length calculated?

I found that after json_encode, the Chinese characters in the array were saved in the database and became unicode.
For example: "I am Chinese",
becomes:

\u6211\u662f\u4e2a\u4e2d\u6587

Originally, "I am Chinese" had a total of 10 characters. After
becomes unicode, does only have a total of 30 characters? ? ?

The text length is 65535. If Chinese characters can be saved directly, there will probably be more than 30,000 Chinese characters.
If it becomes unicode, wouldn’t there only be about 6,500 Chinese characters that can be saved?

If the text length is not enough, change it to mediumtext. Will the database become larger and slower?

There are 3 questions in total, please ask. Sorry for the newbies.

某草草某草草2782 days ago467

reply all(2)I'll reply

  • PHP中文网

    PHP中文网2017-05-16 13:10:03

    Performance will definitely be affected. All usual storage of such large text would create a separate table.

    reply
    0
  • 巴扎黑

    巴扎黑2017-05-16 13:10:03

    YesJSON_UNESCAPED_UNICODE, save Chinese directly without escaping.

    reply
    0
  • Cancelreply