Skip to content

Instantly share code, notes, and snippets.

@panfu
Created December 17, 2009 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save panfu/258516 to your computer and use it in GitHub Desktop.
Save panfu/258516 to your computer and use it in GitHub Desktop.
关于encode的那些事儿
require 'cgi'
require 'uri'
r =<<JS
{
"max_character_length": '140',
"mouseover_active": false,
"hovering_delay": 1000,
"translations": {
"button_change": "Change",
"button_save": "Save",
"button_saving": "Saving...",
"button_saved": "Saved",
"failure_message": "Failed",
"hint_text": "What's up?"
},
"url": "?m=Profile&func=process_set_status&ajax=1&store=0&ajax_target=canvas",
"post_params": {
"viewer_id": 67042802,
"csrf": "5a7e980a"
},
"new_status_param_name": "status_body"
}
JS
# p CGI.escape(r)
puts e = CGI::escapeHTML(r.gsub(/\t|\n/, ''))
puts CGI::unescapeHTML(e)
# p URI.escape(r)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment