gsub non ASCII character in Ruby
I am trying to replace a non ASCII character from a string with the following code:
string.gsub(194.chr,'')
When I do this, I get the following error:
RegexpError: premature end of regular expression: /�/
Can anyone tell me how to a开发者_如何学JAVAchieve this?
>> string="foo\xC2bar"
=> "foo\xC2bar"
>> string.force_encoding"ASCII-8BIT"
=> "foo\xC2bar"
>> string.gsub(194.chr, '')
=> "foobar"
精彩评论