On Mar 31, 2:06 pm, Nanyang Zhan <rails-mailing-l...@andreas-s.net>
wrote:
> Javascript's encodeURIComponent works differently from CGI.eacape or
> ERB::Util.u.

Well the difference is that the javascript stuff is produced UTF16 and
the ruby UTF8 (although the documentation I can find suggests that the
javascript should also be producing utf8).

> for example:
> encodeURIComponent('中文') = '%D6%D0%CE%C4'
> but>> CGI.escape("中文")
>
> => "%E4%B8%AD%E6%96%87">> ERB::Util.u("中文")
>
> => "%E4%B8%AD%E6%96%87"
>
> Is there any way to get the same encoded result with ruby code?

The are various libraries for messing around with string encodings,
including iconv, and pack/unpack have some specifiers that are
relevant for unicode stuff, and rails itself also has various unicode
utilities in it.

Fred

> --
> Posted viahttp://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to