Character encoding wrangling doesn't work in Ruby 1.8. Bypass if not supported.

Strings don't have force_encoding and the Encoding class doesn't exist. Added a little respond_to? check around the call.