I have a Word doc with the following line
“a”
Method 1
Using Win32::OLE to extract the line
my $encoded = encode_entities($line);
print "$encoded\n";
Outputs
“a”
Method 2
Using Win32::OLE to first save as utf8
my $text;
{
open my $fh, '<:utf8', 'utf8.txt';
$text = <$fh>;
close $fh;
}
my $encoded = encode_entities($text);
print "$encoded\n";
Produces:
“a”
I don't believe method 1 output conforms to HTML4.01 but that method 2 does.
I intend to use method 2 but is there a better way to do it?
Update:
For what it's worth the text extracted by method 2 also displays correctly in a tk text widget. :-)
Update 2:
Corrected the HTML spec.
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.