开发者

How to gsub an unicode 0083 with ruby?

I have loaded a string from a html.file, and I have writen it to a yaml file with the plugin ya2yaml:


- title: 'What a wonderful day!'
  body:  ... # main contents here

and I will load the .yml file by YAML::parse_file 开发者_StackOverflow社区method.

but "\n" in the string will cause load problems, so I tried to gsub all "\n" to "", but there is still problems, a char '0083'(I see it in the terminal) still breaks the line, and cause loading problem:


in `load': syntax error on line 32, col 6: `      </strong><br>ok ' (ArgumentError)
from /home/croplio/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/syck.rb:178:in `parse'
from /home/croplio/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/syck.rb:203:in `block in parse_file'
from /home/croplio/.rvm/rubies/ruby-1.9.2-preview3/lib/ruby/1.9.1/syck.rb:202:in `open'

So what's wrong with the yaml or the char 0083?

or how can I avoid this problem?


0083 is a unicode character 'NO BREAK HERE'. I don't know YAML::pars, but maybe you can switch it to use unicodes or use pure ascii codes.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜