Method: HTTPX::ContentType#charset

Defined in:
lib/httpx/response.rb

#charsetObject

returns the charset declared in the header.

ContentType.new("application/json; charset=utf-8").charset #=> "utf-8"
ContentType.new("text/plain").charset #=> nil


230
231
232
233
234
235
# File 'lib/httpx/response.rb', line 230

def charset
  return @charset if defined?(@charset)

  m = @header_value.to_s[CHARSET_RE, 1]
  m && @charset = m.strip.delete('"')
end