Reputation: 45622
I have the following code which requires Ruby 1.9, and I need to achieve the same functionality in Ruby 1.8. How can I accomplish this?
# encoding: UTF-8
... [code omitted]
body.force_encoding("UTF-8")
body = body.gsub(/^(?=>)/, ">").gsub(/^(?!>)/, "> ")
body
is a string obtained from an external source.
I think what I need is called a "shim" but I'm not sure.
Upvotes: 0
Views: 191
Reputation: 160551
James Gray wrote a series of articles about dealing with encodings in Ruby. They're very good reading.
For 1.8.7 the jcode
library can help.
$KCODE = "U"
require 'jcode'
Upvotes: 2