module Octokit::Connection

def response_data_correctly_encoded(response)

def response_data_correctly_encoded(response)
  content_type = response.headers.fetch('content-type', '')
  return response.data unless content_type.include?('charset') && response.data.is_a?(String)
  reported_encoding = content_type.match(/charset=([^ ]+)/)[1]
  response.data.force_encoding(reported_encoding)
end