in reply to Re: path encoding folder
in thread path encoding folder

C:\Documents and Settings\FC\Desktop>perl script.pl SV = PV(0x2e33e00) at 0x2d70c60 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK,UTF8) PV = 0x2e52784 "C:/Documents and Settings/FC/Desktop/\303\274/test.t +xt"\0 [UTF 8 "C:/Documents and Settings/FC/Desktop/\x{fc}/test.txt"] CUR = 48 LEN = 52 SV = PV(0x2e33cf8) at 0x2d70d08 REFCNT = 1 FLAGS = (PADBUSY,PADMY,POK,pPOK) PV = 0x2e58004 "C:/Documents and Settings/FC/Desktop/\374/test.txt"\ +0 CUR = 47 LEN = 48 Tabella codici attiva: 850 Tk::Error: No such file or directory at a.pl line 44. (menu invoke)

Replies are listed 'Best First'.
Re^3: path encoding folder
by ikegami (Patriarch) on Nov 19, 2010 at 19:31 UTC

    getSaveFile appears to return the file name as decoded text. CreateDirectory expects decoded text according to the documentation, so that's good. As for open, it (more or less) expects text encoded using the current locale (unix) or ANSI code page (Windows). GetANSIPathName is there to do that conversion.

    I was trying to use chcp to figure out what's your code page, but it returns the OEM code page. We're interested in the ANSI one. Your ANSI code page is probably cp1252 (a superset of iso-8859-1).

    The output you gave shows that .../ü/test.txt gets properly encoded to cp1252, so everything is fine on the encoding side.

    The output you gave also shows that you are trying to create file .../Desktop/ü/test.txt/test.txt since you append test.txt to the displayed value. (Note the double "test.txt".) I'm guessing directory .../Desktop/ü/test.txt doesn't exist (though I don't know why CreateDirectory didn't given an error when it didn't create it).

    The problem is that you're using the file path as the directory path. That's why it's always a good idea to include the file name in error messages for open.