Parsing string to add to URL-encoded URL

后端 未结 4 1769
误落风尘
误落风尘 2020-12-08 01:25

Given the string:

\"Hello there world\"

how can I create a URL-encoded string like this:

\"Hello%20there%20world\"
<         


        
4条回答
  •  南笙
    南笙 (楼主)
    2020-12-08 02:29

    While the current answer says to utilize URI.encode that has been deprecated and obsolete since Ruby 1.9.2. It is better to utilize CGI.escape or ERB::Util.url_encode.

提交回复
热议问题