Skip to content

Instantly share code, notes, and snippets.

@rhenium
Created August 2, 2013 10:08
Show Gist options
  • Save rhenium/6138828 to your computer and use it in GitHub Desktop.
Save rhenium/6138828 to your computer and use it in GitHub Desktop.
require "base64"
def encode_utf7(str)
str.gsub("+", "+-").gsub(/[^+A-Za-z0-9'(),-.\/:? \t\r\n]+/) {|m| "+" + [[m.each_codepoint.to_a.map{|m| "%04x" % m }.join].pack("H*")].pack("m0").delete("=") + "-" }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment