我不知道这是不是一个愚蠢的问题,但是我搜索了一下,在Rails 4中找不到这样的方法,我需要一个类似rawurlencode的方法,但是对于Rails 4。
来自文档的
Returns a string in which all non-alphanumeric characters except -_.~ have
been replaced with a percent (%) sign followed by two hex digits.
This is the encoding described in » RFC 3986 for protecting literal characters
from being interpreted as special URL delimiters, and for protecting URLs from
being mangled by transmission media with character conversions (like some email
systems).所以,在中有这样的方法吗?
发布于 2013-12-08 02:18:35
URI::escape方法如何?
URI::escape('google.com/?q=what an awesome day')上述方法转义输入字符串,用代码替换所有不安全字符。也就是说,它使用百分比编码来编码输入.您可以阅读更多关于百分比编码的信息:
http://en.wikipedia.org/wiki/Percent-encoding
https://stackoverflow.com/questions/20448695
复制相似问题