Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

String#encode raises when source matches target encoding #2012

Merged
merged 1 commit into from Nov 19, 2012

Conversation

Projects
None yet
3 participants
Contributor

benlangfeld commented Nov 13, 2012

Fix coming as soon as I can figure one out.

Contributor

benlangfeld commented Nov 14, 2012

So I don't have a fix yet, but I've established that the behaviour here should be equivalent to String#force_encoding

@dbussink dbussink and 1 other commented on an outdated diff Nov 17, 2012

spec/ruby/core/string/encode_spec.rb
@@ -58,6 +58,12 @@
str.encoding.should == Encoding::UTF_8
end
+ it "returns self when called when target encoding equals source encoding" do
+ str = "caf\xe9".force_encoding("iso-8859-1")
+ copy = str.encode "iso-8859-1", "iso-8859-1"
+ copy.encoding.should == Encoding::UTF_8
@dbussink

dbussink Nov 17, 2012

Owner

Shouldn't this be Encoding::ISO-8859-1?

@benlangfeld

benlangfeld Nov 17, 2012

Contributor

Yes it should. Typo.

@brixen brixen pushed a commit that referenced this pull request Nov 19, 2012

Brian Ford Merge pull request #2012 from benlangfeld/feature/fix_encoding
String#encode returns self when source matches target encoding.
38d313b

@brixen brixen merged commit 38d313b into rubinius:master Nov 19, 2012

1 check failed

default The Travis build failed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment