Can't insert Chinese character into MySQL

后端 未结 4 1700
闹比i
闹比i 2020-11-28 13:23

The cookie is encoded using the big5 set, and it cannot insert into MySQL. Could you help me to solve this problem?

Fields: username is eng, date1

4条回答
  •  离开以前
    2020-11-28 13:48

    The real problem is about the cookie being encoded big5? Is the rest of the data in the client encoded as utf8? If 'yes' to both, ...

    Change the connection to be big5, do the INSERT/SELECT of the cookie, then change back to utf8 (or, better, utf8mb4 after upgrading).

    Executing SET NAMES big5 or calling the charset('big5') function for the API you are using is the preferred way to switch back and forth.

    (Meanwhile, get away from the mysql_* interface; switch to mysqli_* or PDO.)

    If everything in the client is big5, then there is no need to switch back and forth. Simply declare that the client is using big5. Note: It does not matter whether the table/column is also big5; MySQL will convert between them.

提交回复
热议问题