How many characters can be stored in 4KB?

后端 未结 3 965
孤街浪徒
孤街浪徒 2020-12-08 03:52

How many characters can i store in 4kb when the characters are in utf-8 encoding ?

3条回答
  •  盖世英雄少女心
    2020-12-08 04:11

    A UTF-8 character is from 1-4 bytes, so it depends on what character you are encoding. The majority of english uses 1 byte for each character. Other western languages use 2 bytes. Asian characters can use 4 bytes.

    So the answer is from 1024 to 4096 depending on the characters. Additionally, on a windows environment you may need a 3 byte BOM at the start of the document which will lower the amount of characters that you can fit into 4Kb. See the wikipedia article on UTF-8.

提交回复
热议问题