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 编码 解码
最新推荐文章于 2020-07-12 01:44:30 发布
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