User Tools

Site Tools


listing_20the_20contents_20of_20a_20directory_20_28unicode_29

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
        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 
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: 2024/01/05 00:22 by 127.0.0.1