From: "Matthias Wächter" Date: 2010-06-28T23:44:13+09:00 Subject: Re: Convert \uXXXX to character On 28.06.2010 15:24, Benoit Daloze wrote: > On 28 June 2010 07:39, Markus Schirp wrote: >> IMHO better than eval ;) > > str = '\u041f\u0440\u0438\u0432\u0435\u0442!' > p str.gsub(/\\u(\h{4})/) { > $1.to_i(16).chr('UTF-8') > } Don’t forget that Unicode Code Points not only cover the BMP and can be up to 6 hex digits long [http://en.wikipedia.org/wiki/Unicode#Character_planes_and_blocks]. What do you do if the string contained some escaped backslashes, like in str = '\u041f\\u0440'? Does it contain Surrogates? – Matthias