且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

解析字符串以添加到 URL 编码的 URL

更新时间:2023-02-23 10:01:01

2019 年,URI.encode 已过时,不应使用.

In 2019, URI.encode is obsolete and should not be used.

require 'uri'

URI.encode("Hello there world")
#=> "Hello%20there%20world"
URI.encode("hello there: world, how are you")
#=> "hello%20there:%20world,%20how%20are%20you"

URI.decode("Hello%20there%20world")
#=> "Hello there world"