Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 28 additions & 2 deletions lib/cgi/core.rb
Original file line number Diff line number Diff line change
Expand Up @@ -755,12 +755,38 @@ class InvalidEncoding < Exception; end
#
@@accept_charset="UTF-8" if false # needed for rdoc?

# Return the accept character set for all new CGI instances.
# :call-seq:
# CGI.accept_charset -> encoding_or_encoding_name
#
# Returns the accept character set for any new \CGI instance;
# see CGI.accept_charset=.
def self.accept_charset
@@accept_charset
end

# Set the accept character set for all new CGI instances.
# :call-seq:
# CGI.accept_charset = encoding_or_encoding_name
#
# Sets the accept character set for any new \CGI instance;
# returns the argument.
#
# Argument +encoding_or_encoding_name+ may be
# an {Encoding object}[https://docs.ruby-lang.org/en/master/encodings_rdoc.html#label-Encoding+Objects]
# or an {encoding name}[https://docs.ruby-lang.org/en/master/encodings_rdoc.html#label-Names+and+Aliases]:
#
# require 'cgi'
# CGI.accept_charset # => "UTF-8"
# CGI.accept_charset = Encoding::UTF_8
# CGI.accept_charset # => #<Encoding:UTF-8>
# CGI.accept_charset = 'UTF-8'
# CGI.accept_charset # => "UTF-8"
#
# Note that the argument is stored "as is,"
# and is not checked for validity:
#
# CGI.accept_charset = Object.new
# CGI.accept_charset # => #<Object:0x000002b0eb7250d0>
#
def self.accept_charset=(accept_charset)
@@accept_charset=accept_charset
end
Expand Down
Loading