0

在 ruby​​ 上的 rhomobile 中,我解析文件并保存到 sqlite db 这样的代码

Questions.delete_all()
file_name = File.join(Rho::RhoApplication::get_model_path('app','Settings'), 'questions.txt')
  file = File.new(file_name)

  file.each_line("\n") do |row|
    col = row.split("|")

   @question=Questions.create(
      {"id" => col[0], "question" => col[1],"answered"=>'0',"show"=>'1',"tutorial"=>col[4]}
    )


    break if file.lineno > 1500
  end
file.close

当在字符串中的文本中有单引号又名 ' 时,例如表达式

It's  funny  

然后在解析、保存和填充后我得到

It�s  funny

知道如何解决这个问题以及它来自哪里,来自 Ruby、来自 sqlite 还是来自什么?如何解决?

4

1 回答 1

0

我会检查以确保您的解析没有做一些有趣的事情。Rhodes 在其 ORM 中处理所有必要的转义。我从来没有遇到过数据库中的引号问题。

于 2011-08-29T01:06:34.637 回答