Created
February 22, 2012 17:23
-
-
Save rajasika/1886171 to your computer and use it in GitHub Desktop.
Ruby IMAP snippet
This file contains 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
def send_string_data(str) | |
case str | |
when "" | |
put_string('""') | |
when /[\x80-\xff\r\n]/n | |
# literal | |
send_literal(str) | |
when /[(){ \x00-\x1f\x7f%*"\\]/n | |
# quoted string | |
send_quoted_string(str) | |
else | |
put_string(str) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment