by Richard Russell, September 2014
See also Listing the contents of a directory
The main help documentation contains the routine PROClistdirectory which lists all the files in the current directory, but it only returns ANSI filenames. If a file or directory contains a non-ANSI character (e.g. from a different alphabet) it will be returned as a question mark. If you want to see these names with their true characters you can use the routine listed below. This returns the file and directory names as UTF-8 strings. Note that you will need to select a font which contains the required characters.
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 591, utf8% LOCAL 260 SYS "FindFirstFileW", "*"+CHR$0+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