MySQL stores the difference between full-width characters and half-width characters. mysql stores full-width and half-width characters.
Unfortunately, the company encountered the MYSQL_DATA_TRUNCATED error when testing IM, and the log record still appeared when mysql_stmt_fetch was called. In view of the previous experience, it should be caused by the insufficient length of the binding area of the given result set. No problem was found after repeated checks. I have a correspondence relationship in the Code, such as char (20). In my code, the char buffer [20] array is defined for storage. It seems so correct and perfect. There is no way to print the data of each row, find the line of the error record, and find the font is different from other. For example:
123456789 (halfwidth)
123456789 (full angle)
This is not controlled by spaces, but by full-width control of input methods. For full-width characters, it is twice the length of half-width characters, while MySQL uses UTF-8, so in the database, it is a full-width character with a length of three bytes.
Select length (column) from table_name where ...;
Use this to print the length. At this time, you need to consider the problem that the type length in the code matches the database Field Length, such as full-width or Chinese characters. In the database, char (20) represents 20 characters rather than 20 bytes, therefore, do not use this 20 as the result set length to retrieve data.