+FAT Unicode file names and ff_fopen()

sonycman wrote on Monday, June 05, 2017:


I`am using +FAT version 160919_FreeRTOS_Labs
UTF-16 unicode support is enabled by setting ffconfigUNICODE_UTF16_SUPPORT to 1.
Long file names support is enabled also by setting ffconfigLFN_SUPPORT to 1.

That would let me to use filenames in unicode, i supposed.

But how can I pass a unicode string to ff_fopen() function, if its pcFile parameter have the type of const char *?

How could one open a file which filename is a unicode string?


heinbali01 wrote on Tuesday, June 06, 2017:

Vladimir, I am guessing that you want to see file names in Cyrillic?

The Unicode variant of the library ( ffconfigUNICODE_UTF16_SUPPORT ) has been tested, but it was never included into the top layer: ff_stdio.c

When you use the low-level functions like FF_Open(), you do have Unicode, but you will miss the “file system layer”. Which is no problem if you just have a single volume, an SD-card.

I think I would define a type that holds a character ( of file name ) :

    #if( ffconfigUNICODE_UTF16_SUPPORT != 0 )
        typedef FF_T_WCHAR FileName_t;
        typedef const char FileName_t;
    FF_FILE *ff_fopen( FileName_t *pcFile, const char *pcMode );
    int ff_mkdir( FileName_t *pcPath );
    int ff_rmdir( FileName_t *pcDirectory );
    int ff_remove( FileName_t *pcPath );

heinbali01 wrote on Tuesday, June 06, 2017:

Just checked the above change with ff_stdio.c
I’m afraid it is a lot more work because there are lots of manipulations with the file- and directory-names. Also ff_sys.c will need to be adapted to use Unicode. No quick fix available, I’m afraid

sonycman wrote on Tuesday, June 06, 2017:

Hi, Hein.

Vladimir, I am guessing that you want to see file names in Cyrillic?

I was very confused realising that Unicode enabled file system actually does not support it from the top layer.
But I’am understand its still in development and unfinished.

Maybe, I should try an ANSI OEM code page for extra cyrillic symbols?
Windows 1251 suits me best.
That will let me use the existing top layer interface, with insertion of conversion function (OEM to UTF-16 and vice versa) before making calls to native UTF-16 layer.

I need ff_fopen(), ff_findfirst() and ff_findnext() only for now.

I will be appreciated for any advices.

PS: I’am very liked +FAT at the moment.
Sectors caching and consecutive clusters read (in one driver function call!) is a very nice features!