mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
lib/unicode_normalize/normalize.rb: added US_ASCII
as trivially supported encoding (is always normalized, and may appear mixed in with UTF-8 or other Unicode encodings). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6e9ff5a892
commit
4fda619836
2 changed files with 11 additions and 0 deletions
|
@ -138,6 +138,8 @@ module UnicodeNormalize
|
|||
else
|
||||
raise ArgumentError, "Invalid normalization form #{form}."
|
||||
end
|
||||
elsif encoding == Encoding::US_ASCII
|
||||
string
|
||||
elsif UNICODE_ENCODINGS.include? encoding
|
||||
normalize(string.encode(Encoding::UTF_8), form).encode(encoding)
|
||||
else
|
||||
|
@ -166,6 +168,8 @@ module UnicodeNormalize
|
|||
else
|
||||
raise ArgumentError, "Invalid normalization form #{form}."
|
||||
end
|
||||
elsif encoding == Encoding::US_ASCII
|
||||
true
|
||||
elsif UNICODE_ENCODINGS.include? encoding
|
||||
normalized? string.encode(Encoding::UTF_8), form
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue