8 lines
169 B
Text
8 lines
169 B
Text
|
|
func urlencode(str) {
|
||
|
|
str.gsub!(%r"([^-A-Za-z0-9_.!~*'() ])", {|a| "%%%02X" % a.ord});
|
||
|
|
str.gsub!(' ', '+');
|
||
|
|
return str;
|
||
|
|
}
|
||
|
|
|
||
|
|
say urlencode('http://foo bar/');
|