def URLDecode(str)
str.gsub!(/%[a-fA-F0-9]{2}/) { |x| x = x[1..2].hex.chr }
end
def URLEncode(str)
str.gsub!(/[^\w$&\-+.,\/:;=?@]/) { |x| x = format("%%%x", x[0]) }
end
ruby 编码 解码
最新推荐文章于 2023-03-29 19:10:28 发布
def URLDecode(str)
str.gsub!(/%[a-fA-F0-9]{2}/) { |x| x = x[1..2].hex.chr }
end
def URLEncode(str)
str.gsub!(/[^\w$&\-+.,\/:;=?@]/) { |x| x = format("%%%x", x[0]) }
end