Please define the term "Multi-byte safe" [closed]
When you are dealing with unicode characters, it is not safe to assume that all the characters just take a single byte or char (java). So when reading or parsing a string, you need to take this into consideration.
Here is an excellent article which explains complexities when dealing with Unicode w.r.t Java.
Stored characters can take up an inconsistent number of bytes. A UTF-8 encoded character might take between one (LATIN_CAPITAL_LETTER_A) and four (MATHEMATICAL_FRAKTUR_CAPITAL_G) bytes. Variable width encoding has implications for reading into and decoding from byte arrays.
Not all code points can be stored in a char. The MATHEMATICAL_FRAKTUR_CAPITAL_G example lies in the supplementary range of characters and cannot be stored in 16 bits. It must be represented by two sequential char values, neither of which is meaningful by itself. The Character class provides methods for working with 32-bit code points.
// Unicode code point to char array
char[] math_fraktur_cap_g = Character.toChars(0x1D50A);
精彩评论