SDL/build-scripts
Ryan C. Gordon a5c892d2c3 stdlib: Improve Unicode support and consistency in string comparison functions.
SDL_strcasecmp (even when calling into a C runtime) does not work with
Unicode chars, and depending on the user's locale, might not work with
even basic ASCII strings.

This implements the function from scratch, using "case-folding,"
which is a more robust method that deals with various languages. It
involves a hashtable of a few hundred codepoints that are "uppercase" and
how to map them to lowercase equivalents (possibly increasing the size of
the string in the process). The vast majority of human languages (and
Unicode) do not have letters with different cases, but still, this static
table takes about 10 kilobytes on a 64-bit machine.

Even this will fail in one known case: the Turkish 'i' folds differently
if you're writing in Turkish vs other languages. Generally this is seen as
unfortunate collateral damage in cases where you can't specify the language
in use.

In addition to case-folding the codepoints, the new functions also know how
to decode the various formats to turn them into codepoints in the first
place, instead of blindly stepping by one byte (or one wchar_t) per
character.

Also included is casefolding.txt from the Unicode Consortium and a perl
script to generate the hashtable from that text file, so we can trivially
update this if new languages are added in the future.

A simple test using the new function:

```c
 #include <SDL3/SDL.h>

 int main(void)
 {
     const char *a = "α ε η";
     const char *b = "Α Ε Η";
     SDL_Log("    strcasecmp(\"%s\", \"%s\") == %d\n", a, b, strcasecmp(a, b));
     SDL_Log("SDL_strcasecmp(\"%s\", \"%s\") == %d\n", a, b, SDL_strcasecmp(a, b));
     return 0;
 }
```

Produces:

```
INFO:     strcasecmp("α ε η", "Α Ε Η") == 32
INFO: SDL_strcasecmp("α ε η", "Α Ε Η") == 0
```

glibc strcasecmp() fails to compare a Greek lowercase string to its uppercase
equivalent, even with a UTF-8 locale, but SDL_strcasecmp() works.

Other SDL_stdinc.h functions are changed to be more consistent, which is to
say they now ignore any C runtime and often dictate that only English-based
low-ASCII works with them.

Fixes Issue #9313.
2024-03-29 15:01:40 -04:00
..
SDL_migration.cocci Fixed duplicate SDL_Version change 2024-03-18 13:59:03 -07:00
add-source-to-projects.pl add-source-to-projects.pl: Fix adding files in the base src dir. 2023-10-09 19:19:01 -04:00
android-prefab.sh cmake: no more SDL3_* cache variables 2023-01-31 01:59:21 +01:00
androidbuild.sh Fixed "${folder^}Activity: bad substitution" with bash 3.2 on macOS 2024-03-05 13:35:17 -08:00
androidbuildlibs.sh Allow specifying APP_PLATFORM and APP_ABI on the command line 2023-06-21 13:49:09 -07:00
build-release.py Renamed releaser.py to build-release.py 2024-03-23 16:56:26 -07:00
casefolding.txt stdlib: Improve Unicode support and consistency in string comparison functions. 2024-03-29 15:01:40 -04:00
check_stdlib_usage.py stdlib: qsort and bsearch changes. 2024-03-01 08:28:12 -05:00
clang-format-src.sh Update for SDL3 coding style (#6717) 2022-11-30 12:51:59 -08:00
cmake-toolchain-mingw64-i686.cmake cmake: add winres to the list of potential name rc compilers 2024-03-05 20:38:00 +01:00
cmake-toolchain-mingw64-x86_64.cmake cmake: add winres to the list of potential name rc compilers 2024-03-05 20:38:00 +01:00
cmake-toolchain-qnx-aarch64le.cmake Do not look at local headers when determining features 2023-03-27 15:33:08 -07:00
cmake-toolchain-qnx-x86_64.cmake Do not look at local headers when determining features 2023-03-27 15:33:08 -07:00
codechecker-buildbot.sh cmake: Prefix all options with "SDL_" 2021-10-05 10:45:26 -04:00
create-release.sh Added a script to trigger the release workflow 2024-03-24 07:22:58 -07:00
fnsince.pl Unify all the SDL_*RunApp() functions into just SDL_RunApp() 2022-12-15 08:01:01 -08:00
gen_audio_channel_conversion.c Updated copyright for 2024 2024-01-01 13:15:26 -08:00
gen_audio_resampler_filter.c Updated copyright for 2024 2024-01-01 13:15:26 -08:00
git-pre-push-hook.pl Remove some vim config lines 2023-02-10 11:00:48 +01:00
makecasefoldhashtable.pl stdlib: Improve Unicode support and consistency in string comparison functions. 2024-03-29 15:01:40 -04:00
mkinstalldirs build-scripts: update install-sh and mkinstalldirs from automake-1.16.3 2020-12-24 01:32:10 +03:00
rename_api.py Added migration notes for migrating Steam Input support from SDL2 to SDL3 2023-12-20 14:15:09 -08:00
rename_headers.py Define SDL_PLATFORM_* macros instead of underscored ones (#8875) 2024-01-24 01:40:51 +00:00
rename_macros.py Only retain SDL_* + platform macro's in rename_macros.py 2024-01-26 18:05:49 +01:00
rename_symbols.py Added "--substring" to the help for rename_symbols.py 2023-10-23 09:14:54 -07:00
showrev.sh Switch header convention from `#include "SDL.h"` to `#include <SDL3/SDLh>` 2022-11-26 22:15:18 -08:00
strip_fPIC.sh Fixed crash if initialization of EGL failed but was tried again later. 2015-06-21 17:33:46 +02:00
test-versioning.sh cmake: we only need a C++ compiler for Android, Haiku and UWP 2024-03-11 00:27:54 +01:00
update-copyright.sh Use GNU sed if available 2023-02-06 15:47:16 -08:00
update-version.sh cmake: pass VERSION to project() + don't use SDL_VERSION 2023-01-31 01:59:21 +01:00
updaterev.sh Switch header convention from `#include "SDL.h"` to `#include <SDL3/SDLh>` 2022-11-26 22:15:18 -08:00
wikiheaders.pl wikiheaders.pl: README files are no longer in Windows endline format. 2023-11-30 10:10:04 -05:00