Project

General

Profile

Actions

Bug #8123

closed

Transcoding exception when using replace along with universal_newline

Added by k776 (Kieran Pilkington) over 11 years ago. Updated almost 6 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
1.9.3 and 2.0.0
[ruby-core:53528]

Description

The following can be reproduced on 1.9.3-p385, 1.9.3-p392, and 2.0.0-p0.

body, charset = "hey", "hey".encoding.to_s
body = body.encode('UTF-8', charset,
:invalid => :replace, :undef => :replace,
:replace => '', :universal_newline => true
)
Encoding::ConverterNotFoundError: code converter not found (universal_newline)

However, if you remove ":replace => '', ", then it works as intended.

Seems you can't use the two options together.


Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #12431: Strange behavior of String#encode('UTF-8', 'UTF-8', ...) when the encoding of the source string is not UTF-8ClosedActions

Updated by jsc (Justin Collins) almost 6 years ago

This code appears to be working (not raising an exception) as early as Ruby 2.1.10:

$ ruby -v
ruby 2.1.10p492 (2016-04-01 revision 54464) [x86_64-darwin17.0]
$ irb
2.1.10 :001 > body, charset = "hey", "hey".encoding.to_s
 => ["hey", "UTF-8"]
2.1.10 :002 > body = body.encode('UTF-8', charset,
2.1.10 :003 >     :invalid => :replace, :undef => :replace,
2.1.10 :004 >     :replace => '', :universal_newline => true
2.1.10 :005?>   )
 => "hey"
Actions #2

Updated by duerst (Martin Dürst) almost 6 years ago

  • Related to Bug #12431: Strange behavior of String#encode('UTF-8', 'UTF-8', ...) when the encoding of the source string is not UTF-8 added

Updated by duerst (Martin Dürst) almost 6 years ago

jsc (Justin Collins) wrote:

This code appears to be working (not raising an exception) as early as Ruby 2.1.10:

This may be related to issue #12431 (Strange behavior of String#encode('UTF-8', 'UTF-8', ...) when the encoding of the source string is not UTF-8). This issue was fixed about 2.5 years ago (i.e. Ruby 2.4 timeframe), and the fix was backported back two versions (i.e. Ruby 2.3 and 2.2, if I count correctly).

I'm assigning this (even if maybe only temporarily) to Nobu, because he fixed issue #12431.

Updated by nobu (Nobuyoshi Nakada) almost 6 years ago

  • Status changed from Open to Closed

It seems fixed by #11324.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0