Fratres doctissimi,
I am unfortunate enough to have to use a Windows box at work. I was trying to write a Perl program that extracts data from DOS-encoded text files and puts them into Excel via OLE. However, the Exce file contained garbage instead of Hungarian accents.
(Now, i must admit I am very lame for Microsux-based code pages. Long ago I thought ISO-8859-1 is DOS and ISO-8859-2 is Windows. Later on I believed cp852 is DOS and cp1250 is Windows. Even later on I believed cp437 is DOS and cp1252 is Windows... Now I believe I am either a total asshole or people do mean different things when they so deceptively simply say "CSV file (MS-DOS)". So I have now simpler metaphors: "DOS encoding" is what FAR Manager calls DOS encoding. "Windows encoding" is what FAR Manager calls Windows encoding. Period. :-) )
So I opened up FAR Manager, a typed up a Perl program, in strictly DOS encoding, to test all possible encodings:
use Encode;
use Win32::OLE;
$ex = Win32::OLE->new('Excel.Application');
$book = $ex->Workbooks->Add;
$sheet = $book->Worksheets(1);
$text="árvíztűrő tükörfúrógép";
@encodings= Encode->encodings(":all");
$line=1;
foreach (@encodings) {
$sheet->Cells($line++,1)->{Value}=$_;
$sheet->Cells($line-1,2)->{Value}=encode($_,$text);
};
$book->SaveAs('c:\test.xls');
This put all available encodins and the usual pseudoword used to test all Hungarian accents: 'árvíztűrő tükörfúrógép' (meaning a drilling machine that drills mirrors and is able to survive floods :-) ). Now: ALL of the output was wrong. It meant that on my box it is simply not possible to convert a DOS text to Windows. Maybe not all necessary code pages were installed. Maybe it is a bad idea to convert a Hungarian-accented text with US English Windows. I dunno. But it's strange.
Semper voster,
Shenpen
UPDATE: now looking at "árvíztűrő" even my Linux/Gnome/Galeon box has some problem with accents...
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.