From: meta@... Date: 2014-03-11T19:34:21+00:00 Subject: [ruby-core:61421] [ruby-trunk - Feature #2567] Net::HTTP does not handle encoding correctly Issue #2567 has been updated by mathew murphy. This still seems to be a problem in Ruby 2.1.1p76. Data ends up as ASCII-8BIT even if the server specifies that it's UTF-8 or ISO-8859-1, and I end up with errors when writing it out somewhere else as a result. ---------------------------------------- Feature #2567: Net::HTTP does not handle encoding correctly https://bugs.ruby-lang.org/issues/2567#change-45730 * Author: Ryan Sims * Status: Assigned * Priority: Low * Assignee: Yui NARUSE * Category: lib * Target version: next minor ---------------------------------------- =begin A string returned by an HTTP get does not have its encoding set appropriately with the charset field, nor does the content_type report the charset. Example code demonstrating incorrect behavior is below. #!/usr/bin/ruby -w # encoding: UTF-8 require 'net/http' uri = URI.parse('http://www.hearya.com/feed/') result = Net::HTTP.start(uri.host, uri.port) {|http| http.get(uri.request_uri) } p result['content-type'] # "text/xml; charset=UTF-8" <- correct p result.content_type # "text/xml" <- incorrect; truncates the charset field puts result.body.encoding # ASCII-8BIT <- incorrect encoding, should be UTF-8 =end -- http://bugs.ruby-lang.org/