summaryrefslogtreecommitdiff
path: root/lib/unicode_normalize
diff options
context:
space:
mode:
authorduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-25 11:09:08 +0000
committerduerst <duerst@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-10-25 11:09:08 +0000
commit4fda6198369cb7a83e35e6456a00365ee3095497 (patch)
tree31d60a5e552e628733a37901352c14c844dad31d /lib/unicode_normalize
parent6e9ff5a892e7c53480007e35ef9f988a85cc9338 (diff)
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
Diffstat (limited to 'lib/unicode_normalize')
-rw-r--r--lib/unicode_normalize/normalize.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/unicode_normalize/normalize.rb b/lib/unicode_normalize/normalize.rb
index 97aaedd..0c99024 100644
--- a/lib/unicode_normalize/normalize.rb
+++ b/lib/unicode_normalize/normalize.rb
@@ -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