From 0ed39e3453f0991b7e30f964a6d7de0c7ea2f114 Mon Sep 17 00:00:00 2001 From: Jean byroot Boussier Date: Thu, 17 Feb 2022 15:17:59 +0100 Subject: [PATCH] Stop checking encoding names Comparing the names is much less efficient than comparing the instance directly. It may also change in the future: https://bugs.ruby-lang.org/issues/18576 --- lib/collmex/request.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/collmex/request.rb b/lib/collmex/request.rb index 7f80619..484d515 100644 --- a/lib/collmex/request.rb +++ b/lib/collmex/request.rb @@ -77,7 +77,7 @@ def execute # http://www.collmex.de/faq.html#zeichensatz_import encoded_body = payload.encode("ISO8859-1", undef: :replace) # Do not blow up on undefined characters in ISO8859-1 response = @http.request_post(Collmex::Request.uri.request_uri, encoded_body, Collmex::Request.header_attributes) - response.body.force_encoding("ISO8859-1") if response.body.encoding.to_s == "ASCII-8BIT" + response.body.force_encoding("ISO8859-1") if response.body.encoding == Encoding::BINARY @raw_response[:string] = response.body.encode("UTF-8")