in reply to Re^2: Character encoding in console in Windows
in thread Character encoding in console in Windows
>perl -MDevel::Peek -e"chomp($_=<STDIN>); Dump($_); open($fh, '<', $_) + or die; print <$fh>" C:\Users\ikegami\í.txt SV = PV(0xeaf80) at 0x2f59c8 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x2f3788 "C:\\Users\\ikegami\\\241.txt"\0 CUR = 22 LEN = 80 Died at -e line 1, <STDIN> line 1.
Is that encoded for my ANSI code page (1252) or my OEM code page (437)?
>perl -MDevel::Peek -MEncode -e"Dump(encode('cp1252', chr(0xED))) SV = PV(0x2fa570) at 0x27b210 REFCNT = 1 FLAGS = (TEMP,POK,pPOK) PV = 0x32c24f8 "\355"\0 CUR = 1 LEN = 8 >perl -MDevel::Peek -MEncode -e"Dump(encode('cp437', chr(0xED))) SV = PV(0x30a570) at 0x28b210 REFCNT = 1 FLAGS = (TEMP,POK,pPOK) PV = 0x32c24f8 "\241"\0 CUR = 1 LEN = 8
So open() expects the name to be encoded using the ANSI code page, but it's coming from STDIN in the OEM code page.
>perl -MDevel::Peek -MEncode=from_to -e"chomp($_=<STDIN>); from_to($_, + 'cp437', 'cp1252'); Dump($_); open($fh, '<', $_) or die; print <$fh> +" C:\Users\ikegami\í.txt SV = PV(0x159adc0) at 0x315b58 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x344d258 "C:\\Users\\ikegami\\\355.txt"\0 CUR = 22 LEN = 80 ok
In broad strokes, the OEM code page is the encoding used by console apps, ANSI for others. Now how do you get those code pages? Good question.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Character encoding in console in Windows
by BrowserUk (Patriarch) on Sep 16, 2010 at 07:15 UTC | |
by ikegami (Patriarch) on Sep 16, 2010 at 13:23 UTC | |
by elef (Friar) on Sep 16, 2010 at 18:16 UTC | |
by ikegami (Patriarch) on Sep 18, 2010 at 01:49 UTC | |
by elef (Friar) on Sep 18, 2010 at 08:16 UTC |