Skip to content

Instantly share code, notes, and snippets.

@nahi
Last active Dec 10, 2015
Embed
What would you like to do?
You can create auto-encoding-detection version with your favorite logic. i.e. super(rhs.force_encoding(mydetect(rhs)))
require 'refinement'
module StringForceEncodingConcat
refine String do
def +(rhs)
begin
super
rescue Encoding::CompatibilityError
super(rhs.force_encoding(self.encoding))
end
end
end
end
@nahi
Copy link
Author

nahi commented Jan 9, 2013

No "require 'refinement'" needed ATM.

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