在 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 还是来自什么?如何解决?