Old thread, but just in case anyone happens to stumble against this thread as I did, here is an addition that might be useful.

RTF specs admit non-ansi Unicode characters, by escaping them in decimal format. So in case your string has some non-ansi characters, you will also need to convert them to escaped. Fortunately, Encode can do it for you. Here is an example:

use Modern::Perl; use utf8; use Encode; my $text = "Gen 1:1 Ἐν ἀρχῇ ἐ&# +960;οίησεν ὁ θεὸ +ς τὸν οὐρανὸ&#95 +7; καὶ τὴν γῆν."; $text = encode('cp1253', $text, sub{ sprintf "\\u%d\?", shift }); # cp +1253 is for Greek) $text =~ s/([\x00-\x1F\x7F-\xFF])/"\\'" .(unpack("H2",$1))/eg; say $text;

Output will be:

Gen 1:1 \u7960?\'ed \u7936?\'f1\'f7\u8135? \u7952?\'f0\'ef\u8055?\'e7\'f3\'e5\'ed \u8001? \'e8\'e5\u8056?\'f2 \'f4\u8056?\'ed \'ef\u8016?\'f1\'e1\'ed\u8056?\'ed \'ea\'e1\u8054? \'f4\u8052?\'ed \'e3\u8134?\'ed.

In reply to Re: What Voodoo Encoding does RTF use for > ASCII Chars? by Anonymous Monk
in thread 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.