зеркало из https://github.com/github/ruby.git
lib/unicode_normalize/normalize.rb: Replaced if-else by case in self.normalized? in parallel to r48309.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48338 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
b30ff6839d
Коммит
62b511b6aa
|
@ -1,3 +1,8 @@
|
|||
Sun Nov 9 18:33:33 2014 Martin Duerst <duerst@it.aoyama.ac.jp>
|
||||
|
||||
* lib/unicode_normalize/normalize.rb: Replaced if-else by
|
||||
case in self.normalized? in parallel to r48309.
|
||||
|
||||
Sun Nov 9 18:07:00 2014 Tanaka Akira <akr@fsij.org>
|
||||
|
||||
* test/xmlrpc: Use assert_join_threads.
|
||||
|
|
|
@ -136,7 +136,8 @@ module UnicodeNormalize
|
|||
|
||||
def self.normalized?(string, form = :nfc)
|
||||
encoding = string.encoding
|
||||
if encoding == Encoding::UTF_8
|
||||
case encoding
|
||||
when Encoding::UTF_8
|
||||
case form
|
||||
when :nfc then
|
||||
string.scan REGEXP_C do |match|
|
||||
|
@ -155,9 +156,9 @@ module UnicodeNormalize
|
|||
else
|
||||
raise ArgumentError, "Invalid normalization form #{form}."
|
||||
end
|
||||
elsif encoding == Encoding::US_ASCII
|
||||
when Encoding::US_ASCII
|
||||
true
|
||||
elsif UNICODE_ENCODINGS.include? encoding
|
||||
when **UNICODE_ENCODINGS
|
||||
normalized? string.encode(Encoding::UTF_8), form
|
||||
else
|
||||
raise Encoding::CompatibilityError, "Unicode Normalization not appropriate for #{encoding}"
|
||||
|
|
Загрузка…
Ссылка в новой задаче