ruby中url解码并替换非法字符
url中中文字符解码
str = URI.decode(url_str)
替换非法字符
if ! str.valid_encoding? p str = str.encode("UTF-16be", :invalid=>:replace, :replace=>"?").encode('UTF-8')
end
url中中文字符解码
str = URI.decode(url_str)
替换非法字符
if ! str.valid_encoding? p str = str.encode("UTF-16be", :invalid=>:replace, :replace=>"?").encode('UTF-8')
end