Skip to content

Patch for String#encode(opts) [JRUBY-5633]#29

Closed
lsegal wants to merge 1 commit intojruby:masterfrom
lsegal:JRUBY-5633
Closed

Patch for String#encode(opts) [JRUBY-5633]#29
lsegal wants to merge 1 commit intojruby:masterfrom
lsegal:JRUBY-5633

Conversation

@lsegal
Copy link
Contributor

@lsegal lsegal commented Mar 23, 2011

@lsegal
Copy link
Contributor Author

lsegal commented Mar 23, 2011

Not sure if this is optimally clean code, it could certainly use some DRYing up, but I'm not enough of a wizard with the codebase to see the refactoring path just yet. Feel free to clean it up.

@headius
Copy link
Member

headius commented Mar 26, 2011

The code looks fine to me, but it seems you don't actually do anything with the Hash, right? Perhaps we can add in the little bit of extra logic that gets the encoding from the hash?

@lsegal
Copy link
Contributor Author

lsegal commented Mar 26, 2011

The options hash is the same options hash provided to the other method variants (String#encode(encoding, opts)). The options hash doesn't have an encoding option, only options with which to perform conversion to the Encoding.default_internal encoding. See the docs: http://rubydoc.info/stdlib/core/String:encode

Note that one thing I noticed we might be missing is that: "The last form by default does not raise exceptions but uses replacement strings. " -- this seems to imply that the default value for the :invalid option is :replace. Is that how you interpret it?

@headius
Copy link
Member

headius commented Apr 11, 2011

On most text-encoding systems I've dealt with, "replace" is usually the default for invalidly-encoded characters.

I'll go ahead and pull in your change today and we can improve support through other revs.

@headius
Copy link
Member

headius commented Apr 11, 2011

On second thought, since we have a release going out today, let's defer this to 1.6.2 and we'll try to fill out the functionality a bit more...

@BanzaiMan
Copy link
Member

We should revisit this issue as the 1.6.2 release draws near.

@BanzaiMan
Copy link
Member

Bumpy bump.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants