diff --git a/lib/geocoder/lookups/maxmind.rb b/lib/geocoder/lookups/maxmind.rb index 9ca10504ad317d9b48d48987687a09be7168cea8..537af7113da49058d8993bb94bbba8c502207abf 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