On 28.06.2010 15:24, Benoit Daloze wrote:
> On 28 June 2010 07:39, Markus Schirp <mbj / seonic.net> 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