Skip to content
Browse files

Do not do any utf8 conversion, assume valid data is received

  • Loading branch information...
1 parent ea81ca0 commit 70fb3b62a5c6c4a6ee6ad461e01730ada559cba0 @josevalim josevalim committed Feb 27, 2013
View
1 Gemfile.lock
@@ -7,6 +7,7 @@ GEM
test_declarative (0.0.4)
PLATFORMS
+ java
ruby
DEPENDENCIES
View
8 lib/i18n/backend/transliterator.rb
@@ -1,6 +1,4 @@
# encoding: utf-8
-require 'i18n/core_ext/string/encoding'
-
module I18n
module Backend
module Transliterator
@@ -91,11 +89,9 @@ def approximations
# Add transliteration rules to the approximations hash.
def add(hash)
- hash.keys.each do |key|
- utf8_key = ::String.force_utf8(key)
- hash[utf8_key] = hash.delete(key).to_s
+ hash.each do |key, value|
+ approximations[key.to_s] = value.to_s
end
- approximations.merge! hash
end
end
end
View
13 lib/i18n/core_ext/string/encoding.rb
@@ -1,13 +0,0 @@
-class String
- if Object.const_defined?(:Encoding)
- def self.force_utf8(obj)
- obj.to_s.dup.force_encoding('UTF-8')
- end
- else
- require 'iconv'
-
- def self.force_utf8(obj)
- ::Iconv.conv('UTF-8//IGNORE', 'UTF-8', obj.to_s.dup)
- end
- end
-end
View
3 test/backend/transliterator_test.rb
@@ -1,12 +1,11 @@
# encoding: utf-8
require 'test_helper'
-require 'i18n/core_ext/string/encoding'
class I18nBackendTransliterator < Test::Unit::TestCase
def setup
I18n.backend = I18n::Backend::Simple.new
@proc = lambda { |n| n.upcase }
- @hash = { :"ü" => "ue", :"ö" => "oe" }
+ @hash = { "ü" => "ue", "ö" => "oe", "a" => "a" }
@transliterator = I18n::Backend::Transliterator.get
end

0 comments on commit 70fb3b6

Please sign in to comment.
Something went wrong with that request. Please try again.