Mysql truncate string 4-character UTF-8 encoding & nbsp; now the truncate effect is the same as intercepting a few characters in both Chinese and English. what I achieved is & nbsp; for example, if three Chinese characters can be captured, can the English characters be automatically recognized as nine characters? & Nbsp; If you are a selectleft (find the other party, 3) soy sauce party, then mysql intercepts the string
Mysql intercepts a string with 4 characters UTF-8 encoded
The effect of string truncation is to intercept a few characters regardless of Chinese and English. what I achieved is:
For example, if three Chinese characters can be captured, can the English characters be automatically recognized as nine characters?
If you are using select left ('find the other object', 3), do not waste time.
------ Solution --------------------
Either Chinese or Spanish is a character.
Why do I count Chinese as one Spanish as three?
------ Solution --------------------
Utf8 gets longer. what is the purpose of byte truncation? when the Buffer length is limited, do you want to ensure that Chinese words are not truncated?
You can use mb_substr to concatenate strings one by one to an empty string, and use strlen to determine whether the number of bytes is too long each time.
------ Solution --------------------
First, judge the string to be intercepted, and then mb_substr.
------ Solution --------------------
To write a function by yourself, you can use it as three characters in English !~~ This is no different from a Chinese character !~~