MySQL 的編碼問題

default code…
db : utf8
table : utf8
field : utf8

html default charset=utf8

若在欄位中加入 \”源\” …. 會出現如下列狀況 ….

Illegal mix of collations (utf8_general_ci,IMPLICIT) and (latin1_swedish_ci,COERCIBLE) for operation \’=\’
都已經設成 utf8 了, 哪ㄦ來的 latin1 ?
m ~ .. 用 phpmyadmin 看 mysql 系統變數 or 到 mysql client 下看
\’%char%\’ …. 就可以看到一些參數值仍是 latin

解決方法 :
把 db , table , field 的編碼改成預設的 latin1_swedish_ci
而html 就維持 utf8;

印象中~~~~~….utf8 就是把1~3個 ascii code組合成1個字元,
那 1~3 個 ascii code 存在 latin1 裡應該是 ok 的吧! …..
編碼的工作就交給 browser吧!

but 我覺得好奇的是, html 設成 utf8 , MySQL 設成 utf8 …
那MySQL 收到了 1~3個 Ascii Code 變為1個字元的資料, 它將怎樣收錄到 db 裡?
該不會把4個Ascii Code 分別再編一次吧 ….. ~\”~

Share your vote!


Do you like this post?
  • Fascinated
  • Happy
  • Sad
  • Angry
  • Bored
  • Afraid

One thought on “MySQL 的編碼問題”

  1. 想了想, 在Browser 編碼後, 為啥還要再在 MySQL 選擇編碼系統呢? … 應該是 for 校正用的! 不是再編一次 or other else!
    ex: “許”這個字因為含有跳脫字元, 當設成 Code Page = 950 時, 就可以避免這個問題!
    我想, MySQL 在這個地方也是這個用意吧!

Leave a Reply

Your email address will not be published. Required fields are marked *


Please help to input verification code