Project

General

Profile

Actions

Bug #4053

closed

JSON Extension Uses Iconv

Added by runpaint (Run Paint Run Run) over 13 years ago. Updated almost 13 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 1.9.3dev (2010-11-13 trunk 29773) [x86_64-linux]
Backport:
[ruby-core:33164]

Description

=begin
ext/json/lib/json/editor.rb and ext/json/lib/json/common.rb both require 'iconv' so their use triggers a deprecation warning.
=end

Actions #1

Updated by naruse (Yui NARUSE) over 13 years ago

  • Status changed from Open to Assigned
  • Assignee set to naruse (Yui NARUSE)

=begin
We'll send a patch to upstream and merge it.
=end

Actions #2

Updated by sorah (Sorah Fukumori) over 13 years ago

=begin
patch is here.

diff --git ext/json/lib/json/common.rb ext/json/lib/json/common.rb
index 244634b..f0e34df 100644
--- ext/json/lib/json/common.rb
+++ ext/json/lib/json/common.rb
@@ -1,5 +1,4 @@
require 'json/version'
-require 'iconv'

module JSON
class << self
@@ -346,7 +345,12 @@ module JSON

# Shortuct for iconv.
def self.iconv(to, from, string)
  • Iconv.iconv(to, from, string).first
  • if String.method_defined?(:encode)
  •  string.encode(to, from)
    
  • else
  •  require 'iconv'
    
  •  Iconv.iconv(to, from, string).first
    
  • end
    end
    end

diff --git test/json/test_json_encoding.rb test/json/test_json_encoding.rb
index f5221bb..d7e65a1 100644
--- test/json/test_json_encoding.rb
+++ test/json/test_json_encoding.rb
@@ -6,7 +6,6 @@ when 'pure' then require 'json/pure'
when 'ext' then require 'json/ext'
else require 'json'
end
-require 'iconv'

class TC_JSONEncoding < Test::Unit::TestCase
include JSON
@@ -14,19 +13,21 @@ class TC_JSONEncoding < Test::Unit::TestCase
def setup
@utf_8 = '["© ≠ €!"]'
@parsed = [ "© ≠ €!" ]

  • @utf_16_data = Iconv.iconv('utf-16be', 'utf-8', @parsed.first)
    @generated = '["\u00a9 \u2260 \u20ac!"]'
  • if defined?(::Encoding)
  • if String.method_defined?(:encode)
  •  @utf_16_data = [@parsed.first.encode('utf-16be', 'utf-8')]
     @utf_8_ascii_8bit = @utf_8.dup.force_encoding(Encoding::ASCII_8BIT)
    
  •  @utf_16be, = Iconv.iconv('utf-16be', 'utf-8', @utf_8)
    
  •  @utf_16be = @utf_8.encode('utf-16be', 'utf-8')
     @utf_16be_ascii_8bit = @utf_16be.dup.force_encoding(Encoding::ASCII_8BIT)
    
  •  @utf_16le, = Iconv.iconv('utf-16le', 'utf-8', @utf_8)
    
  •  @utf_16le = @utf_8.encode('utf-16le', 'utf-8')
     @utf_16le_ascii_8bit = @utf_16le.dup.force_encoding(Encoding::ASCII_8BIT)
    
  •  @utf_32be, = Iconv.iconv('utf-32be', 'utf-8', @utf_8)
    
  •  @utf_32be = @utf_8.encode('utf-32be', 'utf-8')
     @utf_32be_ascii_8bit = @utf_32be.dup.force_encoding(Encoding::ASCII_8BIT)
    
  •  @utf_32le, = Iconv.iconv('utf-32le', 'utf-8', @utf_8)
    
  •  @utf_32le = @utf_8.encode('utf-32le', 'utf-8')
     @utf_32le_ascii_8bit = @utf_32le.dup.force_encoding(Encoding::ASCII_8BIT)
    
    else
  •  require 'iconv'
    
  •  @utf_16_data = Iconv.iconv('utf-16be', 'utf-8', @parsed.first)
     @utf_8_ascii_8bit = @utf_8.dup
     @utf_16be, = Iconv.iconv('utf-16be', 'utf-8', @utf_8)
     @utf_16be_ascii_8bit = @utf_16be.dup
    

I putted this patch to upstream.

https://github.com/flori/json/pull/53

-sora_h
=end

Actions #3

Updated by naruse (Yui NARUSE) over 13 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

=begin
This issue was solved with changeset r30004.
Run Paint, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.

=end

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0