From d97f399eaf225920495296ad4d7c44d67a2a3dc6 Mon Sep 17 00:00:00 2001 From: Alex Reisner <alex@alexreisner.com> Date: Fri, 21 Dec 2012 16:36:00 -0500 Subject: [PATCH] Fix Ruby 1.8.7 incompatibility. Need to determine how necessary this encoding is, and how to do it properly in 1.8.7. --- lib/geocoder/lookups/maxmind.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/geocoder/lookups/maxmind.rb b/lib/geocoder/lookups/maxmind.rb index 9ca10504..537af711 100644 --- a/lib/geocoder/lookups/maxmind.rb +++ b/lib/geocoder/lookups/maxmind.rb @@ -29,7 +29,10 @@ module Geocoder::Lookup def parse_raw_data(raw_data) # Maxmind just returns text/plain as csv format but according to documentation, # we get ISO-8859-1 encoded string. We need to convert it. - CSV.parse_line raw_data.force_encoding("ISO-8859-1").encode("UTF-8") + if raw_data.respond_to?(:force_encoding) + raw_data = raw_data.force_encoding("ISO-8859-1").encode("UTF-8") + end + CSV.parse_line encoded end def reserved_result -- GitLab