Guest User

Untitled

a guest
Apr 25th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. class String
  2. def to_quoted_printable(*args)
  3. [self].pack("M").gsub(/\n/, "\r\n")
  4. end
  5. def from_quoted_printable
  6. self.gsub(/\r\n/, "\n").unpack("M").first
  7. end
  8. end
  9.  
  10.  
  11. def quote_text_if_necessary(text)
  12. # text = text.gsub( /[^a-z ]/i ) { quote_char($&) }.
  13. # gsub( / /, "_" )
  14. # text
  15. [text].pack("M").gsub(/\n/, "\r\n")
  16. end
  17.  
  18. def quote_if_necessary(text, charset)
  19. # text = text.gsub( /[^a-z ]/i ) { quote_char($&) }.gsub( / /, "_" )
  20. text = [text].pack("M").gsub(/\n/, "\r\n").gsub( / /, "_" )
  21. "=?#{charset}?Q?#{text}?="
  22. end
Add Comment
Please, Sign In to add comment