From 0deecc781a53f7125abecb4b1d301fb76b6a2bb5 Mon Sep 17 00:00:00 2001 From: Cliff Pruitt Date: Wed, 17 Jul 2019 12:13:09 -0400 Subject: Revert "Make UTF-8 string requirement explicit for `ActiveSupport::Inflector.transliterate`" --- activesupport/lib/active_support/inflector/transliterate.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) (limited to 'activesupport/lib/active_support/inflector/transliterate.rb') diff --git a/activesupport/lib/active_support/inflector/transliterate.rb b/activesupport/lib/active_support/inflector/transliterate.rb index ea7161a6ba..ec6e9ccb59 100644 --- a/activesupport/lib/active_support/inflector/transliterate.rb +++ b/activesupport/lib/active_support/inflector/transliterate.rb @@ -5,9 +5,8 @@ require "active_support/i18n" module ActiveSupport module Inflector - # Replaces non-ASCII characters in a UTF-8 encoded string with an ASCII - # approximation, or if none exists, a replacement character which - # defaults to "?". + # Replaces non-ASCII characters with an ASCII approximation, or if none + # exists, a replacement character which defaults to "?". # # transliterate('Ærøskøbing') # # => "AEroskobing" @@ -57,12 +56,8 @@ module ActiveSupport # # transliterate('Jürgen', locale: :de) # # => "Juergen" - # - # This method requires that `string` be UTF-8 encoded. Passing an argument - # with a different string encoding will raise an ArgumentError. def transliterate(string, replacement = "?", locale: nil) raise ArgumentError, "Can only transliterate strings. Received #{string.class.name}" unless string.is_a?(String) - raise ArgumentError, "Can only transliterate UTF-8 strings. Received string with encoding #{string.encoding}" unless string.encoding == ::Encoding::UTF_8 I18n.transliterate( ActiveSupport::Multibyte::Unicode.tidy_bytes(string).unicode_normalize(:nfc), -- cgit v1.2.3