Author |
Topic: Reading unicode filenames (Read 822 times) |
|
southwest
New Member
member is offline


Gender: 
Posts: 2
|
 |
Reading unicode filenames
« Thread started on: Aug 30th, 2014, 9:30pm » |
|
I'm trying to write a utility to convert utf-8 chars in filenames into their nearest ANSI equivalent, as well as shortening long filenames etc.
When I try to read filenames with the standard SYS FindFirstFile program, unusual chars come out as question marks. *Spool-ing *Dir produces the same result. A rummaging through Google suggests I should be using FindFirstFileW and similar calls, but nothing at all comes back from this.
|
|
Logged
|
|
|
|
rtr2
Guest
|
 |
Re: Reading unicode filenames
« Reply #1 on: Aug 30th, 2014, 9:55pm » |
|
on Aug 30th, 2014, 9:30pm, southwest wrote:Google suggests I should be using FindFirstFileW and similar calls, but nothing at all comes back from this. |
|
FindFirstFileW works for me:
Code: CP_UTF8 = &FDE9
VDU 23,22,640;512;8,16,16,128+8 : REM Select UTF-8 mode
*font Courier New
PROClistdirectory_utf8
END
DEF PROClistdirectory_utf8
LOCAL dir%, sh%, res%, utf8%
DIM dir% LOCAL 317, utf8% LOCAL 260
SYS "FindFirstFileW", "*"+CHR$0+CHR$0, dir% TO sh%
IF sh% <> -1 THEN
REPEAT
SYS "WideCharToMultiByte", CP_UTF8, 0, dir%+44, -1, utf8%, 260, 0, 0
PRINT $$utf8%
SYS "FindNextFileW", sh%, dir% TO res%
UNTIL res% = 0
SYS "FindClose", sh%
ENDIF
ENDPROC
|
|
Logged
|
|
|
|
southwest
New Member
member is offline


Gender: 
Posts: 2
|
 |
Re: Reading unicode filenames
« Reply #2 on: Aug 30th, 2014, 10:09pm » |
|
Interesting.
I thought the SYS/API parameters were identical from the C examples I could find, I suspected they were not, but further searching proved fruitless.
Thanks for pointing me in the right direction.
|
« Last Edit: Aug 30th, 2014, 10:09pm by southwest » |
Logged
|
|
|
|
|