-1

I am writing a script to extract search terms from URLs, but I need to humanize them and many of them have special URL encoded characters in them. I was wondering if there was a gem or some built in function in Ruby to convert these to plain text? Or will I have to write my own functions to clean them up?

4

1 回答 1

2

您可以CGI::unescape用于 URL 解码:

require 'cgi'
string = CGI::unescape("1+%2B+2+%3D+3")
#=> "1 + 2 = 3"
于 2013-06-20T21:44:56.167 回答