instance method
valid_encoding
Ruby on Rails 7.2.3
Since v3.0.20 PrivateSignature
valid_encoding(string, encoding)
No documentation comment.
Parameters
-
stringreq -
encodingreq
Source
# File actionview/lib/action_view/template/handlers/erb.rb, line 95
def valid_encoding(string, encoding)
# If a magic encoding comment was found, tag the
# String with this encoding. This is for a case
# where the original String was assumed to be,
# for instance, UTF-8, but a magic comment
# proved otherwise
string.force_encoding(encoding) if encoding
# If the String is valid, return the encoding we found
return string.encoding if string.valid_encoding?
# Otherwise, raise an exception
raise WrongEncodingError.new(string, string.encoding)
end
Defined in actionview/lib/action_view/template/handlers/erb.rb line 95
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionView::Template::Handlers::ERB