WCF
WCF copied to clipboard
Unify string ordering functions
trafficstars
we currently have:
<=>: https://github.com/WoltLab/WCF/blob/ce4b59bfbf770fb5a88105fd3205f60ea6039181/wcfsetup/install/files/lib/acp/form/LanguageImportForm.class.php#L174strcmp: https://github.com/WoltLab/WCF/blob/ce4b59bfbf770fb5a88105fd3205f60ea6039181/wcfsetup/install/files/lib/acp/form/BoxAddForm.class.php#L267-L270strcasecmp: https://github.com/WoltLab/WCF/blob/ce4b59bfbf770fb5a88105fd3205f60ea6039181/wcfsetup/install/files/lib/acp/form/DataImportForm.class.php#L138-L141
They should all be unified to use <=>. strcmp is a direct replacement. strcasecmp will need to either call strtolower or mb_strtolower depending on whether the strings hold Unicode values or not.
Maybe a helper function should be introduced for the case-insensitive comparison. It could use Collator::compare() when intl is available.
when intl is available.
Intl is always available now and it likely makes sense to use Collator even for case-sensitive comparisons to correctly handle accented characters.