in reply to Escaping Wide Characters

eval-ing the resulting string should be sufficient (\x{....} and \x.. is how you can specify characters in a literal double quoted string (where .. are hex numbers)).

Update: maybe I should add that, depending on security context (e.g. if someone malicious could have modified the string returned from nice_string() in the meantime), you might not want to blindly eval an arbitrary string...  In that case, you could extract the \x{....} sequences etc. using a regex, and convert the chars individually back to unicode with pack("U", hex(...))

Replies are listed 'Best First'.
Re^2: Escaping Wide Characters
by mobiusinversion (Beadle) on Mar 05, 2008 at 18:03 UTC
    oh and this too:
    my($x,$y) = ('\x{263a}',undef); eval "$y = $x";
Re^2: Escaping Wide Characters
by Anonymous Monk on Mar 05, 2008 at 17:59 UTC
    thanks for the reply. how do you eval it? for example, this does not seem to work:
    my($x,$y) = ('\x{263a}',undef); eval '$y = $x';
    and this does not compile:
    my($x,$y) = ('\x{263a}',undef); $y = eval($x);
    what am i doing wrong?

      You need to put double quotes around the string, e.g.

      my $x = '\x{263a}'; my $y = eval '"'.$x.'"'; # or my $y = eval "\"$x\"";