From: sprite Date: 2010-09-03T05:55:21+09:00 Subject: Re: Unescaping hex encoded characters in string? On Sep 2, 3:26 am, Robert Klemme wrote: > On Thu, Sep 2, 2010 at 7:45 AM, sprite 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 seehttp://blog.grayproductions.net/articles/miscellaneous_m17n_details > > Kind regards > > robert > > -- > remember.guy do |as, often| as.you_can - without endhttp://blog.rubybestpractices.com/ Thanks