Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/i18n/backend/transliterator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def initialize(rule = nil)
def transliterate(string, replacement = nil)
replacement ||= DEFAULT_REPLACEMENT_CHAR
string.gsub(/[^\x00-\x7f]/u) do |char|
approximations[char] || replacement
approximations[char] || (replacement == :none ? char : replacement)
end
end

Expand Down
4 changes: 4 additions & 0 deletions test/backend/transliterator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def setup
assert_equal "abc#", @transliterator.transliterate("abcſ", "#")
end

test "can keep non-ASCII chars not in map with :none" do
assert_equal "abcſ", @transliterator.transliterate("abcſ", :none)
end

test "default transliterator raises errors for invalid UTF-8" do
assert_raises ArgumentError do
@transliterator.transliterate("a\x92b")
Expand Down
Loading