hi, for example, I have an string "q1 q2 q3". how can I encode it in rails to produce the result like "q1%20q2%20q3". Thanks! Best Regards, Zhenjian -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060717/3824f992/attachment.html
Bruno Celeste
2006-Jul-17 07:35 UTC
[Rails] how to do url encoding for given text in rails?
CGI::escape("your text") On 7/17/06, Zhenjian YU <zhenjian@gmail.com> wrote:> hi, > > for example, I have an string "q1 q2 q3". how can I encode it in rails to > produce the result like > "q1%20q2%20q3". > > Thanks! > > Best Regards, > Zhenjian > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
Chris Parsons
2006-Jul-17 07:45 UTC
[Rails] Re: how to do url encoding for given text in rails?
On 17/07/2006 08:32, Zhenjian YU wrote:> for example, I have an string "q1 q2 q3". how can I encode it in rails > to produce the result like > "q1%20q2%20q3".If you just want to URL encode, you can use CGI.escape: require ''cgi'' puts CGI.escape "q1 q2 q3" => q1+q2+q3 Hope this helps, Chris
Zhenjian YU
2006-Jul-17 07:59 UTC
[Rails] Re: how to do url encoding for given text in rails?
thank, all it works On 7/17/06, Chris Parsons <chris.p@rsons.org> wrote:> > On 17/07/2006 08:32, Zhenjian YU wrote: > > for example, I have an string "q1 q2 q3". how can I encode it in rails > > to produce the result like > > "q1%20q2%20q3". > > If you just want to URL encode, you can use CGI.escape: > > require ''cgi'' > puts CGI.escape "q1 q2 q3" > > => q1+q2+q3 > > Hope this helps, > > Chris > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060717/17eaf0f2/attachment-0001.html