diff --git a/ChangeLog b/ChangeLog index d06cc619c9..f725a5c9fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Sun Nov 9 18:33:33 2014 Martin Duerst + + * 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 * test/xmlrpc: Use assert_join_threads. diff --git a/lib/unicode_normalize/normalize.rb b/lib/unicode_normalize/normalize.rb index 5fea8c5548..86e83f2afe 100644 --- a/lib/unicode_normalize/normalize.rb +++ b/lib/unicode_normalize/normalize.rb @@ -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}"