Created
June 27, 2012 18:35
-
-
Save osheroff/3005917 to your computer and use it in GitHub Desktop.
marshal utf-8 enforcement
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Marshal | |
class << self | |
def load_with_utf8_enforcement(object, other_proc=nil) | |
@utf8_proc ||= Proc.new do |o| | |
o.force_encoding("UTF-8") if o.is_a?(String) | |
other_proc.call(o) if other_proc | |
o | |
end | |
load_without_utf8_enforcement(object, @utf8_proc) | |
end | |
alias_method_chain :load, :utf8_enforcement | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment