rightmove_wrangler 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rightmove_wrangler/version.rb +1 -1
- data/lib/rightmove_wrangler.rb +14 -15
- metadata +1 -1
data/lib/rightmove_wrangler.rb
CHANGED
@@ -208,22 +208,21 @@ module RightmoveWrangler
|
|
208
208
|
return false
|
209
209
|
end
|
210
210
|
end
|
211
|
-
end
|
212
211
|
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
212
|
+
def force_convert_utf8(string)
|
213
|
+
begin
|
214
|
+
# Try it as UTF-8 directly
|
215
|
+
cleaned = string.dup.force_encoding('UTF-8')
|
216
|
+
unless cleaned.valid_encoding?
|
217
|
+
# Some of it might be old Windows code page
|
218
|
+
cleaned = string.encode( 'UTF-8', 'Windows-1252' )
|
219
|
+
end
|
220
|
+
utf8_string = cleaned
|
221
|
+
rescue EncodingError
|
222
|
+
# Force it to UTF-8, throwing out invalid bits
|
223
|
+
utf8_string = string.encode!( 'UTF-8', invalid: :replace, undef: :replace )
|
224
|
+
end
|
225
|
+
utf8_string
|
225
226
|
end
|
226
|
-
utf8_string
|
227
227
|
end
|
228
|
-
|
229
228
|
end
|