Skip to main content
Associate
June 10, 2026
Solved

FileX with file unicode 16 bit characters

  • June 10, 2026
  • 7 replies
  • 101 views

I need to create, read and modify files using filex. Such files have names that uses cyrillic characters set (they must be codified using unicode 16 bit). It is possible to manage such files? 

Thanks

Best answer by MFARH.1

hello ​@Gengiz ,

Yes, FileX supports file names containing Cyrillic characters through its 16-bit Unicode APIs.

In practice, the file must first be created or renamed using the Unicode services, such as fx_unicode_file_create(...) or fx_unicode_file_rename(...). Once this is done, the generated short name can be used with the standard FileX APIs such as fx_file_open(...), fx_file_read(...), and fx_file_write(...).
 

Example:

UCHAR unicode_name[] = {
    0x14, 0x04,  /* Д */
    0x30, 0x04,  /* а */
    0x3D, 0x04,  /* н */
    0x3D, 0x04,  /* н */
    0x4B, 0x04,  /* ы */
    0x35, 0x04,  /* е */
    0x2E, 0x00,  /* . */
    0x74, 0x00,  /* t */
    0x78, 0x00,  /* x */
    0x74, 0x00,  /* t */
    0x00, 0x00
};

CHAR short_name[13];
FX_FILE file;
ULONG length;
ULONG bytes_read;
CHAR buffer[20];
UINT status;

length = fx_unicode_length_get(unicode_name);

status = fx_unicode_file_create(&media, unicode_name, length, short_name);
status = fx_file_open(&media, &file, short_name, FX_OPEN_FOR_WRITE);
status = fx_file_write(&file, "Bonjour", sizeof(“Bonjour”));
status = fx_file_close(&file);

status = fx_file_open(&media, &file, short_name, FX_OPEN_FOR_READ);
status = fx_file_read(&file, buffer, sizeof(“Bonjour”), &bytes_read);
status = fx_file_close(&file);

 

Regards,

Maher

 

 

7 replies

ST Technical Moderator
June 11, 2026

Hello ​@Gengiz 

Yes, FileX can handle filenames with Cyrillic characters, provided you use the Unicode filename APIs and the filesystem is configured with Long File Name (LFN) support. In practice, filenames must be passed as 16-bit Unicode strings to the corresponding FileX Unicode services for file or directory creation/opening. Standard read/write operations on the file content remain unchanged once the file is opened. So, if LFN/Unicode support is enabled in the FileX configuration, creating, reading, and modifying files whose names contain Cyrillic characters is supported.

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
GengizAuthor
Associate
June 19, 2026

Now I use  fx_file_create(), fx_file_open(), fx_file_close() and read and write.

 

It will work if I call:

uint16_t NameFile[10];

FX_FILE File; 

NameFile[0]= 0x418;           //‘И’

NameFile[0]=0x43C;           //’м’

NameFile[0]=0x435;           //’е’

NameFile[0]=0;

fx_filex_create(#disk#, NameFile);

fx_filex_open(File,NameFile, READ_ONLY);

Andrew Neil
Super User
June 19, 2026

NameFile[0]= 0x418;           //‘И’

NameFile[0]=0x43C;           //’м’

NameFile[0]=0x435;           //’е’

NameFile[0]=0;

That will give you an empty string!

I presume you meant:

NameFile[0]= 0x418;          //‘И’
NameFile[1]=0x43C; //’м’
NameFile[2]=0x435; //’е’
NameFile[3]=0;

 

And please note how to properly post source code

 

A complex system that works is invariably found to have evolved from a simple system that worked.A complex system designed from scratch never works and cannot be patched up to make it work.
GengizAuthor
Associate
June 19, 2026

Or should I set any properly #define?

MFARH.1
MFARH.1Best answer
ST Employee
June 19, 2026

hello ​@Gengiz ,

Yes, FileX supports file names containing Cyrillic characters through its 16-bit Unicode APIs.

In practice, the file must first be created or renamed using the Unicode services, such as fx_unicode_file_create(...) or fx_unicode_file_rename(...). Once this is done, the generated short name can be used with the standard FileX APIs such as fx_file_open(...), fx_file_read(...), and fx_file_write(...).
 

Example:

UCHAR unicode_name[] = {
    0x14, 0x04,  /* Д */
    0x30, 0x04,  /* а */
    0x3D, 0x04,  /* н */
    0x3D, 0x04,  /* н */
    0x4B, 0x04,  /* ы */
    0x35, 0x04,  /* е */
    0x2E, 0x00,  /* . */
    0x74, 0x00,  /* t */
    0x78, 0x00,  /* x */
    0x74, 0x00,  /* t */
    0x00, 0x00
};

CHAR short_name[13];
FX_FILE file;
ULONG length;
ULONG bytes_read;
CHAR buffer[20];
UINT status;

length = fx_unicode_length_get(unicode_name);

status = fx_unicode_file_create(&media, unicode_name, length, short_name);
status = fx_file_open(&media, &file, short_name, FX_OPEN_FOR_WRITE);
status = fx_file_write(&file, "Bonjour", sizeof(“Bonjour”));
status = fx_file_close(&file);

status = fx_file_open(&media, &file, short_name, FX_OPEN_FOR_READ);
status = fx_file_read(&file, buffer, sizeof(“Bonjour”), &bytes_read);
status = fx_file_close(&file);

 

Regards,

Maher

 

 

GengizAuthor
Associate
June 19, 2026

Yes. It was a mistake the index all the time set to 0

GengizAuthor
Associate
June 19, 2026

Thanks.