GB2312VSUTF-8 of PHP character encoding problems. Today, I wrote some code according to the book. the code intends to use the str_split () function to split the string into an array. it is easy to say in English, but Chinese is separated (two Chinese characters and one array unit) today, I wrote some code according to the book. the code is intended to use the str_split () function to split the string into arrays. it is easy to say in English, but Chinese is separated (two Chinese characters and one array unit) there is a problem --
Check the code:
> Http://www.w3.org/TR/html4/loose.dtd ">
New Document
$ String1 = "I am a phper ";
$ String2 = "this book is a blue ocean strategy ";
Print_r (str_split ($ string1 ));
Echo"
";
Print_r (str_split ($ string2, 4 ));
?>
I expected the test results to be output-Chinese garbled characters
Why? Why? Why? Why? What is garbled code? What is garbled? Explain to me what is % & garbled!
Because English without garbled characters, only Chinese garbled characters, first of all think of the encoding problem, so suddenly think of the UTF-8 encoding is UTF-8 needs 3 bytes, dead horse as a doctor!
Therefore, print_r (str_split ($ string2, 4); 4 in this sentence is changed to 6, and the result is almost -- view the result
Similarly, you can also try to change the UTF-8 of charset encoding to GB2312, because Unicode encoding requires 2 bytes, so the Gb2312 encoding can save 1/3 of the space than the UTF-8, but if you want to be compatible with other languages of traditional Chinese, Korean, and Japanese, you need to use UTF-8.
By the way, I found the first dynamic Music and shared it with me:
-Its OK?
-Its OK!
When the merge () function is split into arrays, the English language is good, but the Chinese language is separated (two Chinese characters and one array unit...