a5c892d2c3
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. |
||
---|---|---|
.. | ||
README-android.md | ||
README-cmake.md | ||
README-contributing.md | ||
README-dynapi.md | ||
README-emscripten.md | ||
README-gdk.md | ||
README-git.md | ||
README-hg.md | ||
README-highdpi.md | ||
README-ios.md | ||
README-kmsbsd.md | ||
README-linux.md | ||
README-macos.md | ||
README-main-functions.md | ||
README-migration.md | ||
README-n3ds.md | ||
README-ngage.md | ||
README-platforms.md | ||
README-porting.md | ||
README-ps2.md | ||
README-psp.md | ||
README-raspberrypi.md | ||
README-riscos.md | ||
README-touch.md | ||
README-versions.md | ||
README-visualc.md | ||
README-vita.md | ||
README-wayland.md | ||
README-windows.md | ||
README-winrt.md | ||
README.md | ||
doxyfile | ||
release_checklist.md |
README.md
Simple DirectMedia Layer
Simple DirectMedia Layer is a cross-platform development library designed to provide low level access to audio, keyboard, mouse, joystick, and graphics hardware. It is used by video playback software, emulators, and popular games including Valve's award winning catalog and many Humble Bundle games.
SDL officially supports Windows, macOS, Linux, iOS, and Android. Support for other platforms may be found in the source code.
SDL is written in C, works natively with C++, and there are bindings available for several other languages, including C# and Python.
This library is distributed under the zlib license, which can be found in the file "LICENSE.txt".
Information on building SDL with CMake is available in README-cmake.md
The best way to learn how to use SDL is to check out the header files in the "include" subdirectory and the programs in the "test" subdirectory. The header files and test programs are well commented and always up to date.
Information on reporting bugs and contributing is available in README-contributing.md
More documentation and FAQs are available online at the wiki
If you need help with the library, or just want to discuss SDL related issues, you can join the SDL Discourse, which can be used as a web forum or a mailing list, at your preference.
If you want to report bugs or contribute patches, please submit them to our bug tracker
Enjoy!
Sam Lantinga mailto:slouken@libsdl.org