File tree Expand file tree Collapse file tree 1 file changed +3
-1
lines changed
activesupport/lib/active_support/inflector Expand file tree Collapse file tree 1 file changed +3
-1
lines changed Original file line number Diff line number Diff line change @@ -62,10 +62,12 @@ module Inflector
62
62
# Transliteration is restricted to UTF-8, US-ASCII, and GB18030 strings.
63
63
# Other encodings will raise an ArgumentError.
64
64
def transliterate ( string , replacement = "?" , locale : nil )
65
- string = string . dup if string . frozen?
66
65
raise ArgumentError , "Can only transliterate strings. Received #{ string . class . name } " unless string . is_a? ( String )
67
66
raise ArgumentError , "Cannot transliterate strings with #{ string . encoding } encoding" unless ALLOWED_ENCODINGS_FOR_TRANSLITERATE . include? ( string . encoding )
68
67
68
+ string = string . dup if string . frozen?
69
+ return string if string . ascii_only?
70
+
69
71
input_encoding = string . encoding
70
72
71
73
# US-ASCII is a subset of UTF-8 so we'll force encoding as UTF-8 if
You can’t perform that action at this time.
0 commit comments