inblosam has asked for the wisdom of the Perl Monks concerning the following question:

I noticed an issue where all my hyphens are removed with RTF::Writer. I pass in a variable that contains the text, and if any hyphens are present they do not show up in the RTF document.
$some_text = 'Hello this-is-a-hyphenated-sentence'; $rtf->paragraph( \'\fs24', $some_text ); }
Even when I just write in a hyphen it is removed, as in:
$rtf->paragraph( \'\fs24\b', "Anniversary-Date: $anniv_date",\'\line' );
They hyphen is just removed and so the words are scrunched together.

Is there something I have to do to allow for hyphenations or something?

Thanks


Michael Jensen

Replies are listed 'Best First'.
Re: RTF::Writer hyphens removed
by ikegami (Patriarch) on Jul 06, 2005 at 22:11 UTC

    paragraph is expecting to be gives some rich text, yet you are passing it plain text. Use rtfesc to fix special characters such as "-".

    use RTF::Writer qw( rtfesc ); $some_text = 'Hello this-is-a-hyphenated-sentence'; $rtf->paragraph( \'\fs24', rtfesc($some_text) ); $rtf->paragraph( \'\fs24\b', rtfesc("Anniversary-Date: $anniv_date"), \'\line' ); # or $rtf->paragraph( \'\fs24\b', rtfesc("Anniversary-Date: $anniv_date\n") );
      I tried the rtfesc and I get really weird characters in my RTF...

      With the text: 'It-has-some-dashes' it shows:

      It\_has\_some\_dashes\'2e

      I did just as explained above.


      Michael Jensen
        Sorry, I was sure I had figured it out -- I have no experience with the module or with RTF -- but it seems I was wrong.
Re: RTF::Writer hyphens removed
by GrandFather (Saint) on Jul 06, 2005 at 22:19 UTC

    The following from RTF spef 1.6 may be of use:

    • \pgnhnsm Em-dash (—) separator character.
    • \pgnhnsn En-dash (–) separator character.
    • \emdash Em-dash (—).
    • \endash En-dash (–).
    • \- Optional hyphen.
    • \_ Nonbreaking hyphen.

    Perl is Huffman encoded by design.