1. Ruby DBI launch operation in Mysql with conditions as follow:
a) The Character encoding of MYSQL table is UTF-8
b) If the encoding of Ruby file is "UTF-8" without BOM, then we need to convert the Chinese character using
If IDE is using ANSI as default,then not need to convert the encoding.
a) The Character encoding of MYSQL table is UTF-8
b) If the encoding of Ruby file is "UTF-8" without BOM, then we need to convert the Chinese character using
name="你好"
name = Iconv.new("GBK", "UTF-8").iconv(name)
sqlstr = "insert into test(name) values('#{name}')"
dbh.execute(sqlstr)
If IDE is using ANSI as default,then not need to convert the encoding.