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:
duerst 2014-10-25 11:09:08 +00:00
Родитель 6e9ff5a892
Коммит 4fda619836
2 изменённых файлов: 11 добавлений и 0 удалений

Просмотреть файл

@ -1,3 +1,10 @@
Sat Oct 25 20:09:09 2014 Martin Duerst <duerst@it.aoyama.ac.jp>
* 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).
Sat Oct 25 20:01:01 2014 Martin Duerst <duerst@it.aoyama.ac.jp> Sat Oct 25 20:01:01 2014 Martin Duerst <duerst@it.aoyama.ac.jp>
* test/test-unicode_normalize.rb: added * test/test-unicode_normalize.rb: added

Просмотреть файл

@ -138,6 +138,8 @@ module UnicodeNormalize
else else
raise ArgumentError, "Invalid normalization form #{form}." raise ArgumentError, "Invalid normalization form #{form}."
end end
elsif encoding == Encoding::US_ASCII
string
elsif UNICODE_ENCODINGS.include? encoding elsif UNICODE_ENCODINGS.include? encoding
normalize(string.encode(Encoding::UTF_8), form).encode(encoding) normalize(string.encode(Encoding::UTF_8), form).encode(encoding)
else else
@ -166,6 +168,8 @@ module UnicodeNormalize
else else
raise ArgumentError, "Invalid normalization form #{form}." raise ArgumentError, "Invalid normalization form #{form}."
end end
elsif encoding == Encoding::US_ASCII
true
elsif UNICODE_ENCODINGS.include? encoding elsif UNICODE_ENCODINGS.include? encoding
normalized? string.encode(Encoding::UTF_8), form normalized? string.encode(Encoding::UTF_8), form
else else