Skip to content

Instantly share code, notes, and snippets.

@nahi
Last active December 10, 2015 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nahi/4449729 to your computer and use it in GitHub Desktop.
Save nahi/4449729 to your computer and use it in GitHub Desktop.
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