diff --git a/ChangeLog b/ChangeLog index e886a6508e..24cfad0fc3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Sat Oct 25 20:09:09 2014 Martin Duerst + + * 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 * test/test-unicode_normalize.rb: added diff --git a/lib/unicode_normalize/normalize.rb b/lib/unicode_normalize/normalize.rb index 97aaeddbee..0c99024c86 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