String#encode with undef replace options problem #881

Closed
seban opened this Issue Jul 12, 2013 · 3 comments

Projects

None yet

3 participants

@seban
seban commented Jul 12, 2013

I am now switching my app from old jruby-1.6.8 to new 1.7.4 but I have issue with String#encode method.

1.9.3p385 :003 > "Pojemność".encode(Encoding::US_ASCII, { :undef => :replace, :replace => ""})
 => "Pojemno"

2.0.0p247 :002 > "Pojemność".encode(Encoding::US_ASCII, { :undef => :replace, :replace => ""})
 => "Pojemno"

jruby-1.6.8 :001 >
jruby-1.6.8 :001 > "Pojemność".encode(Encoding::US_ASCII, { :undef => :replace, :replace => ""})
 => "Pojemno"

jruby-1.7.0 :001 > "Pojemność".encode(Encoding::US_ASCII, { :undef => :replace, :replace => ""})
 => "Pojemno??"

jruby-1.7.4 :001 > "Pojemność".encode(Encoding::US_ASCII, { :undef => :replace, :replace => ""})
 => "Pojemno??"

It looks like :replace option is totally not used in this method. Is it not supported in Jruby 1.7 branch or I just doing something wrong?

@lowang
lowang commented Jul 12, 2013

problems is also visible in 1.7.1, 1.7.2 & 1.7.3

@headius
Member
headius commented Jul 12, 2013

Fixing.

@headius headius added a commit that closed this issue Jul 12, 2013
@headius headius Rework encoding replacement to handle zero-length replace string.
Our logic only allowed single-char replacements through, since
that is what NIO supports, but zero-char replacement basically
maps to the IGNORE action in NIO. This patch makes that change.

Fixes #881.
edf3a18
@headius headius closed this in edf3a18 Jul 12, 2013
@lowang
lowang commented Jul 12, 2013

wow, thanks for super fast response 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment