The problem of a Chinese character equal to several bytes in java

I have seen many posts before that a Chinese character is equal to 2 bytes, but this is not entirely true.

If the encoding method is GBK, then a Chinese character is indeed equal to 2 bytes, and a Chinese comma is equal to 2 bytes.

If the encoding method is UTF-8, then a Chinese character is equal to 3 bytes, and a Chinese comma is equal to 3 bytes.


This is when I recently discovered this problem when pushing things to Apple servers. By default, the maximum message received by the Apple server is 256 bytes.

Guess you like

Origin blog.csdn.net/lileronglilerong/article/details/43233093