If I have a string like "Don\x{2019}t Let Me Fall"
How do I unescape the hex encoded characters, in this cae convert the
string to "Don't Let Me Fall"
on 2010-09-02 07:45
on 2010-09-02 09:29
On Thu, Sep 2, 2010 at 7:45 AM, sprite <aake.gregertsen@gmail.com> wrote: > If I have a string like "Don\x{2019}t Let Me Fall" > > How do I unescape the hex encoded characters, in this cae convert the > string to "Don't Let Me Fall" In Ruby 1.9.* something along the lines of str.gsub /\\x\{(\h{4})\}/ do |code| code.to_i(16).chr(str.encoding) # code.to_i(16).chr(Encoding::UTF_8) end Or use gsub! for inplace modification of the string. You might have to twiddle with the encodings. Please see http://blog.grayproductions.net/articles/miscellaneous_m17n_details Kind regards robert
on 2010-09-02 23:01
On Sep 2, 3:26 am, Robert Klemme <shortcut...@googlemail.com> wrote: > # code.to_i(16).chr(Encoding::UTF_8) > remember.guy do |as, often| as.you_can - without endhttp://blog.rubybestpractices.com/ Thanks
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.