ITeye博客

Ruby Tips

jacky · 2008-07-01 23:46 · ruby & rails · Markdown

  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


   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.

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。