Forum: Ruby-core [ruby-trunk - Bug #6675][Open] Raise exception when convert encoding of a character from GBK to UTF

Posted by mghomn (Justin Peal) (Guest)
on 2012-06-30 08:14
(Received via mailing list)
Issue #6675 has been reported by mghomn (Justin Peal).

----------------------------------------
Bug #6675: Raise exception when convert encoding of a character from GBK 
to UTF
https://bugs.ruby-lang.org/issues/6675

Author: mghomn (Justin Peal)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]


#!/usr/bin/env ruby -w
# encoding: utf-8

require 'test/unit'

class Tests < Test::Unit::TestCase
  def test_gbk
    assert_raise Encoding::UndefinedConversionError do
      "\ue863".encode('gbk').encode('utf-8')
    end
  end
end
Posted by naruse (Yui NARUSE) (Guest)
on 2012-07-02 03:03
(Received via mailing list)
Issue #6675 has been updated by naruse (Yui NARUSE).

Status changed from Open to Feedback

The test passes my environment:
* ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin11.4.0]
* ruby 1.9.3p203 (2012-05-04 revision 35536) [x86_64-freebsd9.0]
* ruby 1.9.3p243 (2012-06-28 revision 36244) [x86_64-freebsd9.0]
* ruby 2.0.0dev (2012-07-02 trunk 36265) [x86_64-freebsd9.0]

Anyone can reproduce it?
----------------------------------------
Bug #6675: Raise exception when convert encoding of a character from GBK 
to UTF
https://bugs.ruby-lang.org/issues/6675#change-27700

Author: mghomn (Justin Peal)
Status: Feedback
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]


#!/usr/bin/env ruby -w
# encoding: utf-8

require 'test/unit'

class Tests < Test::Unit::TestCase
  def test_gbk
    assert_raise Encoding::UndefinedConversionError do
      "\ue863".encode('gbk').encode('utf-8')
    end
  end
end
Posted by "Martin J. Dürst" <duerst@it.aoyama.ac.jp> (Guest)
on 2012-07-02 09:20
(Received via mailing list)
\ue863 is in the Unicode private use area. Therefore, conversion to GBK
should not succeed. I get Encoding::UndefinedConversionError just for
    ruby -e '"\ue863".encode("gbk")'

I don't understand why the title of the bug is "when convert ... from
GBK to UTF-8". The last method call of the test, .encode('utf-8'), is
quite irrelevant. Justin, can you explain what you want?

Regards,   Martin.
Posted by mame (Yusuke Endoh) (Guest)
on 2012-11-02 12:22
(Received via mailing list)
Issue #6675 has been updated by mame (Yusuke Endoh).

Status changed from Feedback to Rejected

No feedback, closing.

2012/7/2 "Martin J. Dürst" <duerst@it.aoyama.ac.jp>:
> \ue863 is in the Unicode private use area. Therefore, conversion to GBK
> should not succeed. I get Encoding::UndefinedConversionError just for
>    ruby -e '"\ue863".encode("gbk")'
>
> I don't understand why the title of the bug is "when convert ... from GBK to
> UTF-8". The last method call of the test, .encode('utf-8'), is quite
> irrelevant. Justin, can you explain what you want?

I guess Justen expected round-trip.

--
Yusuke Endoh <mame@tsg.ne.jp>
----------------------------------------
Bug #6675: Raise exception when convert encoding of a character from GBK 
to UTF
https://bugs.ruby-lang.org/issues/6675#change-32233

Author: mghomn (Justin Peal)
Status: Rejected
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]


#!/usr/bin/env ruby -w
# encoding: utf-8

require 'test/unit'

class Tests < Test::Unit::TestCase
  def test_gbk
    assert_raise Encoding::UndefinedConversionError do
      "\ue863".encode('gbk').encode('utf-8')
    end
  end
end
Posted by mghomn (Justin Peal) (Guest)
on 2012-12-06 09:10
(Received via mailing list)
Issue #6675 has been updated by mghomn (Justin Peal).


# Because GBK is narrow, now I use GB18030 to avoid this error. :-)

#!/usr/bin/env ruby -w
# encoding: utf-8

require 'test/unit'

class Tests < Test::Unit::TestCase
  def test_gbk
    "\ue863".encode('gb18030').encode('utf-8')
  end
end
----------------------------------------
Bug #6675: Raise exception when convert encoding of a character from GBK 
to UTF
https://bugs.ruby-lang.org/issues/6675#change-34461

Author: mghomn (Justin Peal)
Status: Rejected
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: ruby 1.9.3p194 (2012-04-20) [i386-mingw32]


#!/usr/bin/env ruby -w
# encoding: utf-8

require 'test/unit'

class Tests < Test::Unit::TestCase
  def test_gbk
    assert_raise Encoding::UndefinedConversionError do
      "\ue863".encode('gbk').encode('utf-8')
    end
  end
end
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.