I'm using templates that will eventually create RTF docs. All is well until (stop me if you've heard this one before...) non-ASCII characters. Rerun!!

But wait!! This is actually a little bit different. According to the RTF specification on encoding there's two kinds. Either \'HEX or \uVOODOO. Why there's two kinds is beyond me, nor have I figured out when to use one or the other.

So while I struggle on with the above, I have this problem here:

If I create a RTF document in OS-X with the TextEdit program and put some nice accents in it, like say:

à, è, ì, ò, ù

Then they are encoded in the document as: \'e0, \'e8, \'ec, \'f2, \'f9

Can anyone help me figure out by what witchcraft this was done, because straight up
$x =~ s/([\x00-\x1F\ x7F-\xFF])/"\\'" .(unpack("H2",$1))/eg;
Doe not work.

And don't get me started on using Unicode::Escape, it's too slow and also doesn't match the RTF specs.

Urgh!!

Tosh

In reply to What Voodoo Encoding does RTF use for > ASCII Chars? by tosh

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.