Crate dbxcase

Source
Expand description

This crate implements the case-folding rules used by Dropbox for file paths.

It’s a recreation of what Python 2.5’s unicode.lower() did (which was the current version of Python at the time of Dropbox’s founding).

For every character in the Unicode 4.1 character database which has a “simple lowercase mapping” property, it replaces it with the corresponding character.

This is different from a proper lowercasing, where at least one upper-case codepoint (U+0130, “Latin Capital Letter I with Dot Above”) maps to two lower-case codepoints. It also uses a very old version of Unicode which lacks many characters added since 2003.

The mapping is hardcoded, but the code can be regenerated manually from the Unicode database using an included program in the codebase.

Constants§

MAP
The mapping from upper-case characters to lower-case characters, excluding ASCII A-Z (check for those separately, since they are so common).

Functions§

dbx_eq_ignore_case
Check whether two strings are equal, ignoring case. See dbx_lowercase.
dbx_lowercase
Case-fold a character to lower-case, using the same rules as Dropbox uses for file paths. If the character is not an upper-case character according to the mapping, returns the original character unchanged.
dbx_str_lowercase
Case-fold a string to lower-case. See dbx_lowercase.
dbx_strip_prefix_ignore_case
Returns a string slice with the prefix removed, ignoring case. See dbx_lowercase and str::strip_prefix.