I want to generate RTF-documents where special characters that look like 
"a@" are translated into ANSI values depending on which font the user would 
like to have. I am using the module RTF::Writer to generate RTF-files from 
perl.

The conversion as such is done via a hash of hashes (thanks Marcus 
Holland-Moritz!). At present, the code looks like this:

use RTF::Writer;

my %converthash = (
'AAA' => { # AAA = font name
'a@' => 'ANSI224', # how to code ANSI numbers so that they get recognized 
in printing RTF further below?
'i@ => 'ANSI228',
},

'BBB' => { # BBB = font name
'a@' => 'ANSI153',
'i@' => 'ANSI245',
},
);

my $data = "some text containing a@s and i@s";
my $string = "AAA"; # contains user input of font name

$data =~ s/$_/$converthash{$string}{$_}/g for keys %{$converthash{$string}};

my $rtf = RTF::Writer->new_to_file("somefile.rtf");
       $rtf->prolog( 'title' => "sometitle",
                'fonts' => "$string"
        );

       $rtf->number_pages;
       $rtf->paragraph(
       \'\par', "$data"
       );

       $rtf->close;


My question now is how to actually code the ANSI values in the hash of 
hashes so that they get written to the RTF document properly. Do I have to 
carry out some conversion process in between? I thought I could simply use 
RTF's escape sequences, like \'ef for i diaresis, but that doesn't work 
(even if I escape characters like \ or ' properly in the hash declaration). 
The escape sequences show up literally in the final RTF document and are 
not interpreted.
Note that the ANSI characters I am using are not part of one consistent 
language specification or covered by one particular code-set. I have to 
directly access their values.

I realize that this is probably more of an RTF question, but thought to ask 
here first as the RTF-file is generated via a perl module and as there 
might just be some steps in perl that I'm missing out on.

Birgit Kellner




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to