Mysql string truncation mysql & nbsp; 4-character string truncation & nbsp; UTF-8 encoding & nbsp; & nbsp; the effects of string truncation are the same now & nbsp; that is, the number of characters intercepted & nbsp; regardless of Chinese and English, what I achieved is & nbsp; for example, if the Chinese character can be truncated by 3 characters, 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 !~~