User Tools

Site Tools


Listing the contents of a directory (Unicode)

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
        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
            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%
This website uses cookies. By using the website, you agree with storing cookies on your computer. Also you acknowledge that you have read and understand our Privacy Policy. If you do not agree leave the website.More information about cookies
listing_20the_20contents_20of_20a_20directory_20_28unicode_29.txt · Last modified: 2018/04/17 17:57 by tbest3112