News:

Download Pelles C here: http://www.pellesc.se

Main Menu

Recent posts

#71
Assembly discussions / Re: Find characters inside a s...
Last post by TimoVJL - August 30, 2026, 10:13:35 AM
An interesting code.
Erol, can you add a comments to that code too, so it explain register usage for bytes better.
#72
Expert questions / Re: _readdir() translates some...
Last post by TimoVJL - August 30, 2026, 10:10:24 AM
As linux support UTF-8 in it functions, it handle internet data and files well.
MS Windows and msvc have a some support for it too, codepage 65001 ?

An universal code needs special (POSIX ?) code / libraries that supports UTF-8 for MS Windows.

UTF-8 functions are naturally slower than pure ANSI / UNICODE versions.
#73
Assembly discussions / Re: Find characters inside a s...
Last post by Vortex - August 27, 2026, 01:16:02 PM
Function determining the extension of a file. FindExt is based on FindChar.

OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

FindExt PROC src:DWORD

    mov     eax,DWORD PTR [esp+4]
    dec     eax
    mov     cl,'.'
@@:
    inc     eax
    mov     dl,BYTE PTR [eax]
    test    dl,dl
    setz    dh
    xor     dl,cl
    setz    ch
    or      ch,dh
    jz      @b
    retn    4

FindExt ENDP

OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef
#74
Expert questions / Re: _readdir() translates some...
Last post by John Z - August 27, 2026, 09:02:17 AM
Hi,

Well here is Mr. Sanders brief:
"The libdirtrav library provides a way to recursively read folder contents using callback functions. This is done using opendir() and readdir() functions, except for Windows where native FindFirstFile()/FindFirstFileEx() and FindNextFile() functions are used. On Windows a wide version is available which uses wchar_t* as string type for Unicode UTF-16 support"

So one sees he also recommends FindFirst etc for windows.

There are two issues 1) codepages being used for Filenames  2) codepages being used within a program or data.  #1 is most difficult to handle as you pointed out it is possible in windows which uses UTF-16 to have many different languages for filenames .  #2 is not so hard.  Most legacy programs or data files have some identifier to inform about the codepage.  VCF contact files for example before VCF 3 used CHARSET=  some name (not always standardized).  VCF3 pushed UTF-8 as a recommendation and VCF4 requires it.

Handling codepage changes within a program is not difficult.  In most cases the end user will be able to see the information is weird so can change the codepage and re-read the data.  An example dialog from my vCardz_i program for vcf contact cards for changing the code page as needed.  Data is read in as binary and and converted from the codepage into UTF-8 or UTF-16 to display.  If looks bogus another codepage can be selected, tedious to be sure and hopefully not often needed. 

John Z
#75
Expert questions / Re: _readdir() translates some...
Last post by Robert - August 27, 2026, 01:47:01 AM
Brecht Sanders has a cross-platform library specific to readdir.

https://github.com/brechtsanders/libdirtrav

Warning! I have not tried using it, so I have no idea if it will work with Pelles C.

CodePages ?
The example file, "Art of Beksiński 1978 (MHS) (2).jpg", includes Polish characters. What if the next file is "Miró's L'escala de l'evasió.jpg"? How could you know that the filename is Spanish? And even if your app could figure that out, how could you switch codepages within the app?

#76
Expert questions / Re: _readdir() translates some...
Last post by John Z - August 26, 2026, 09:34:41 PM
Hi,

You've not mentioned whether coding for DOS or Windows, Linux?
These non-std functions were provide to improve portability according to the help file.

Windows filenames are all in Unicode UTF-16.  However AFAIK all OS files are ASCII and ASCII is supported intact within the lower UTF-16 codes, so 98% of the files on the system can be opened without using wide.  The other 2% are user files which can be using any character in the UTF-16 set, which includes all (well almost all) characters sets in the world. A swag as the percentages but you get the gist.

IMO, you are better off using _wfindfirst64,  and associated functions, then you are covered for all language nuances.

Otherwise codepages are not hard to use, the hard part is figuring out which one to activate.... :(

John Z
#77
Expert questions / Re: _readdir() translates some...
Last post by RobertSteed - August 26, 2026, 08:12:04 PM
Quote from: John Z on August 23, 2026, 10:09:58 PMHi,

Well first I've never used these functions so a grain of salt with my comments.

Looking into the header there is no Unicode or wide character support for the functions.  So support will be limited to code pages.  If using ANSI code page ( I guess for the UK ?) for example then the 233 é  exists and can be shown.  However the ANSI code page does not include an n with diacritic in fact the only n is 241 ñ, so the closest substitution is made.

So try a different code page?  I was going to suggest trying to get the 8.3 filename but it seems the same issue would hinder that too.

John Z

For example codepage 852  E4 is n with diacritic
Cheers. I'm loathe to use codepages! What do you do for this kind of thing where you're dealing with Unicode file names? I guess the wide-character versions might work.
#78
Expert questions / Re: _readdir() translates some...
Last post by RobertSteed - August 26, 2026, 08:09:52 PM
Quote from: TimoVJL on August 23, 2026, 02:08:45 PMFunction fopen might be a problem too, as it works with ANSI filenames.
I did some tests, even i don't like those functions, as i rather use Win32 API.
That's a good point. What do you use for Unicode files?
Why do you use the Win32 API rather than _findfirst64() etc?
#79
Assembly discussions / Re: Find characters inside a s...
Last post by Vortex - August 26, 2026, 07:07:38 PM
Another version assuming that the string to be searched contains only printable characters :

OPTION PROLOGUE:NONE
OPTION EPILOGUE:NONE

FindChar PROC src:DWORD,char:DWORD

    mov     eax,DWORD PTR [esp+4]
    mov     ecx,DWORD PTR [esp+8]
    dec     eax
@@:
    inc     eax
    mov     dl,BYTE PTR [eax]
    mov     dh,dl
    xor     dl,cl
    sub     dx,0101h
    or      dl,dh
    cmp     dl,255
    jnz     @b
    retn    8

FindChar ENDP

OPTION PROLOGUE:PrologueDef
OPTION EPILOGUE:EpilogueDef
#80
Assembly discussions / Re: Find characters inside a s...
Last post by jack - August 25, 2026, 02:26:56 AM
👍