in reply to Re^2: How to open SQL 2005 errorlog?
in thread How to open SQL 2005 errorlog?
Ahh... the first two bytes (ÿþ = 0xFF 0xFE) most likely is a BOM (Byte Order Mark), indicating that the file is UTF-16le or UCS-2le (le=little-endian) encoded (the distinction between UTF-16 and UCS-2 is probably irrelevant in your case — what's essential is that (at least) two bytes are being used to encode a single character).
In order to properly read such files, you need to open them like this:
unless (open LOG, "<:encoding(ucs-2)", $sqlErrorlog) { ...
or
unless (open LOG, "<:encoding(utf-16)", $sqlErrorlog) { ...
(you need Perl 5.8.x for this to work)
When debug-printing your $_, you should then see the line content as expected.
Just in case you're still having problems (in particular with line endings), you might want to see this post of mine, which describes the problem, and a workaround. Good luck.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: How to open SQL 2005 errorlog?
by jc7 (Initiate) on Jun 07, 2007 at 17:57 UTC | |
by almut (Canon) on Jun 07, 2007 at 20:53 UTC | |
by jc7 (Initiate) on Jun 08, 2007 at 20:50 UTC | |
by almut (Canon) on Jun 08, 2007 at 22:40 UTC | |
by jc7 (Initiate) on Jun 12, 2007 at 16:35 UTC |