因而,要获得以utf - 8编码的字符串的正确长度,必须使用mb_strlen (string,“ utf - 8 ”),而不只是strlen (string)。
So, to get the correct length of string encoded in utf-8, you have to use mb_strlen (string, "utf-8") instead of just strlen (string).
I certainly don't want to assume they're always going to type a three-letter or a four-letter or a two-letter word I want some dynamism but that's fine because get string can get a string of any length, I can then use the string length function to just ask while the program is running how big is the string that I was handed?
当然我不能假设他总是,输入3个字符或4个字符,或2个字符的单词,我想要动态地分配,因为GetString可以获得任意长度的字符串,然后我可以使用strlen函数,来得到那个我传递的字符串,有多长?
应用推荐