Advertisement
Guest User

Untitled

a guest
Jan 21st, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. def escape(x)
  2.  
  3. if (x.encoding.to_s != "ASCII-8BIT")
  4. raise "wtf"
  5. end
  6.  
  7. r = x.empty? ? "%" : CGI.escape(x).gsub("%20", '+')
  8.  
  9. if (r.encoding.to_s != "ASCII-8BIT")
  10. raise "wtf"
  11. end
  12.  
  13. r
  14. end
  15.  
  16. def unescape(x)
  17. x == "%" ? "" : CGI.unescape(x, "ASCII-8BIT")
  18. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement