diff --git a/lib/oofatfs/ffunicode.c b/lib/oofatfs/ffunicode.c index 26ac738507..a04577616a 100644 --- a/lib/oofatfs/ffunicode.c +++ b/lib/oofatfs/ffunicode.c @@ -499,7 +499,7 @@ DWORD ff_wtoupper ( /* Returns up-converted code point */ DWORD uni /* Unicode code point to be up-converted */ ) { - #if FF_FS_ASCII_UPPER_ONLY + #if FF_FS_CASE_INSENSITIVE_COMPARISON_ASCII_ONLY // Only uppercase ASCII characters. Everything else will require the user to // pass in an uppercase version. if ('a' <= uni && uni <= 'z') { diff --git a/ports/unix/mpconfigport.h b/ports/unix/mpconfigport.h index c54fede813..c94845229c 100644 --- a/ports/unix/mpconfigport.h +++ b/ports/unix/mpconfigport.h @@ -178,6 +178,9 @@ #define MICROPY_FATFS_RPATH (2) #define MICROPY_FATFS_MAX_SS (4096) #define MICROPY_FATFS_LFN_CODE_PAGE 437 /* 1=SFN/ANSI 437=LFN/U.S.(OEM) */ +#define MICROPY_FATFS_LFN_UNICODE (2) + +#define FF_FS_CASE_INSENSITIVE_COMPARISON_ASCII_ONLY (1) // Define to MICROPY_ERROR_REPORTING_DETAILED to get function, etc. // names in exception messages (may require more RAM). diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 6b9ded9294..a514b6a160 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -595,7 +595,7 @@ void supervisor_run_background_tasks_if_tick(void); #define CIRCUITPY_DIGITALIO_HAVE_INVALID_DRIVE_MODE (0) #endif -#define FF_FS_ASCII_UPPER_ONLY (1) +#define FF_FS_CASE_INSENSITIVE_COMPARISON_ASCII_ONLY (1) #define FF_FS_MAKE_VOLID (1) diff --git a/tests/extmod/vfs_fat_case.py b/tests/extmod/vfs_fat_case.py index 45496dcf81..40d67da9b8 100644 --- a/tests/extmod/vfs_fat_case.py +++ b/tests/extmod/vfs_fat_case.py @@ -51,18 +51,29 @@ vfs = uos.VfsFat(bdev) uos.mount(vfs, "/ramdisk") uos.chdir("/ramdisk") +vfs.label = "labelæ" +# This label would normally be LABELÆ but our limited upper casing does "LABELæ" +print(vfs.label) + # Check ASCII case-insensitivity -vfs.mkdir("foo_dir_az") +vfs.mkdir("fooaz") print(uos.listdir("")) -vfs.rmdir("fOO_dir_AZ") +vfs.rmdir("fOOAZ") + +# Check ASCII case-insensitivity for long names (8+ characters) +vfs.mkdir("123456789fooaz") +print(uos.listdir("")) +vfs.rmdir("123456789fOOAZ") # Characters outside of a-z are case sensitive. vfs.mkdir("extended_æ") print(uos.listdir("")) +# Normally this would work ok. With our limited uppercasing, it won't. try: vfs.rmdir("extended_Æ") except OSError as e: print(e.errno == uerrno.ENOENT) + vfs.rmdir("extended_æ") # Emoji test for fun. diff --git a/tests/extmod/vfs_fat_case.py.exp b/tests/extmod/vfs_fat_case.py.exp index 0089bc9b51..64b5e7b27a 100644 --- a/tests/extmod/vfs_fat_case.py.exp +++ b/tests/extmod/vfs_fat_case.py.exp @@ -1,3 +1,5 @@ -['foo_dir_az'] +LABELæ +['fooaz'] +['123456789fooaz'] ['extended_æ'] True