encode_utf7(s)
public
Encode a string from UTF-8 format to modified UTF-7.
Show source
def self.encode_utf7(s)
return s.gsub(/(&)|([^\x20-\x7e]+)/u) { |x|
if $1
"&-"
else
base64 = [u8tou16(x)].pack("m")
"&" + base64.delete("=\n").tr("/", ",") + "-"
end
}
end