简体   繁体   中英

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 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM