Thanks,
almut -
This solved part of the problem. The file is now getting read in OK and the expected regex matches occur. However, the output is still causing problem because the non-ASCII characters in it do not get represented correctly. I have tried the following two approaches:
1) Printing out to the DOS console and redirecting the output from there into a file. The result looks fine - if it were not for the special characters that get represented as
EF,
FC etc.
2) Printing to a UTF-16 encoded file with the following code:
#! /usr/bin/perl -w
use strict;
use locale;
open INPUT, "<:encoding(UTF-16LE)", $ARGV[0];
open OUTPUT, ">:encoding(UTF-16LE)", "./Output_UTF-16";
while ( <INPUT> )
{
# long list of regex-based replacements
print OUTPUT $_;
}
The result was an output file which represented all special characters correctly but contained a line of empty boxes in every second line.
Can you please advise what I need to do to fix both output variants?
Thanks again for your help!
Pat
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.