summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-01 16:26:15 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-12-01 16:26:15 +0000
commit521876c373ba3d1fac5de2dfe82539d98381bc10 (patch)
treed84c3a56d8a8b637226142718a73282663618ed0 /ext
parent4a84c27e3ee50c4989591fcde2b7a10c5ccc0395 (diff)
* ext/json/lib/json/common.rb: don't use iconv on 1.9.
patched by Shota Fukumori [ruby-core:33164] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30004 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext')
-rw-r--r--ext/json/lib/json/common.rb12
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/json/lib/json/common.rb b/ext/json/lib/json/common.rb
index d5444b92c82..13debd1366c 100644
--- a/ext/json/lib/json/common.rb
+++ b/ext/json/lib/json/common.rb
@@ -1,5 +1,4 @@
require 'json/version'
-require 'iconv'
module JSON
class << self
@@ -342,8 +341,15 @@ module JSON
end
# Shortuct for iconv.
- def self.iconv(to, from, string)
- Iconv.iconv(to, from, string).first
+ if String.method_defined?(:encode)
+ def self.iconv(to, from, string)
+ string.encode(to, from)
+ end
+ else
+ require 'iconv'
+ def self.iconv(to, from, string)
+ Iconv.iconv(to, from, string).first
+ end
end
end