# File lib/sinatra/respond_to.rb, line 190 def charset(val=nil) fail "Content-Type must be set in order to specify a charset" if response['Content-Type'].nil? if response['Content-Type'] =~ /charset=[^;]+/ response['Content-Type'].sub!(/charset=[^;]+/, (val == '' && '') || "charset=#{val}") else response['Content-Type'] += ";charset=#{val}" end unless val.nil? response['Content-Type'][/charset=([^;]+)/, 1] end