in reply to Re: What Voodoo Encoding does RTF use for > ASCII Chars?
in thread What Voodoo Encoding does RTF use for > ASCII Chars?

Does it suffice for you? Because for me I get the following:
my $x = "foo à, è, ì, ò, ù bar"; $x =~ s/([\x00-\x1F\x7F-\xFF])/"\\'" .(unpack("H2",$1))/eg; print $x; # WHAT I WANT: foo \'e0, \'e8, \'ec, \'f2, \'f9 bar # What I get foo \'c3\'a0, \'c3\'a8, \'c3\'ac, \'c3\'b2, \'c3\'b9 bar
Vexing...

Replies are listed 'Best First'.
Re^3: What Voodoo Encoding does RTF use for > ASCII Chars?
by Eliya (Vicar) on Mar 20, 2012 at 22:31 UTC

    Judging by your output, your problem is that your string (source code) is UTF-8 encoded, but you have not told Perl about it.

    use utf8 if your source code is in UTF-8.  In case the data comes from elsewhere, decode it properly before using it.

    The UTF-8 encoding of the character 'à' (for example) is the two bytes c3 a0, so if you don't tell Perl that those two bytes are supposed to be decoded into one character, you'll have them incorrectly interpreted as the two latin-1 characters \xc3 and \xa0.