rfc:strtolower-ascii
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:strtolower-ascii [2021/09/24 03:18] – remove "consequent changes" since nikic will merge most of them separately without an RFC tstarling | rfc:strtolower-ascii [2021/11/25 05:02] – add vote tstarling | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PHP RFC: Locale-independent case conversion ====== | ====== PHP RFC: Locale-independent case conversion ====== | ||
- | * Version: 1.1 | + | * Version: 1.2 |
* Date: 2021-09-22 | * Date: 2021-09-22 | ||
* Author: Tim Starling < | * Author: Tim Starling < | ||
- | * Status: | + | * Status: |
* Target version: PHP 8.2 | * Target version: PHP 8.2 | ||
* Implementation: | * Implementation: | ||
Line 40: | Line 40: | ||
===== Proposal ===== | ===== Proposal ===== | ||
- | |||
- | ==== Main changes ==== | ||
The following PHP string functions will do ASCII case conversion: | The following PHP string functions will do ASCII case conversion: | ||
Line 61: | Line 59: | ||
Note that strcasecmp(), | Note that strcasecmp(), | ||
- | |||
- | php_strtolower() and php_strtoupper() are the internal C API equivalent of strtoupper() and strtolower(). After reviewing the callers of these functions in the core tree, I decided that they should also be part of this change. They will henceforth do ASCII case conversion. | ||
- | |||
- | For consistency, | ||
ASCII case conversion is identical to case conversion with the " | ASCII case conversion is identical to case conversion with the " | ||
- | |||
- | ==== New functions ==== | ||
- | |||
- | I am proposing that locale-sensitive case conversion be provided by functions called ctype_tolower() and ctype_toupper(). Effectively, | ||
- | |||
- | * tolower() and toupper() are in ctype.h, so it fits with ctype' | ||
- | * The limitations of the implementation are shared by the other ctype functions and so are less likely to be surprising. | ||
- | * The result is consistent with ctype_islower() and ctype_isupper(). | ||
- | * It's easy to do, and maybe someone will want them. | ||
- | |||
- | Some statements in the manual about what the ctype extension is for will have to be updated. | ||
- | |||
- | For completeness, | ||
===== Alternatives considered ===== | ===== Alternatives considered ===== | ||
Line 94: | Line 75: | ||
It is not possible for strtolower() to raise a deprecation warning depending on its input, because there is no way to tell whether a given case transformation was intended by the caller. | It is not possible for strtolower() to raise a deprecation warning depending on its input, because there is no way to tell whether a given case transformation was intended by the caller. | ||
+ | |||
+ | I considered introducing ctype_tolower() and ctype_toupper(), | ||
===== Future Scope ===== | ===== Future Scope ===== | ||
Line 99: | Line 82: | ||
I didn't include strnatcasecmp() and natcasesort() in this RFC, because they also use isdigit() and isspace(), and because they are intended for natural language processing. They could be migrated in future. | I didn't include strnatcasecmp() and natcasesort() in this RFC, because they also use isdigit() and isspace(), and because they are intended for natural language processing. They could be migrated in future. | ||
- | There are about 50 direct callers of tolower() and toupper() which I haven' | + | There are about 50 direct callers of tolower() and toupper() which I haven' |
- | ===== Proposed | + | ===== Voting ===== |
- | The introduction of ctype_tolower() and ctype_toupper() can be a separate vote, if they seem controversial during the discussion stage. | + | Voting period: 2021-11-25 to 2021-12-09. |
+ | <doodle title=" | ||
+ | * Yes | ||
+ | * No | ||
+ | </ | ||
rfc/strtolower-ascii.txt · Last modified: 2021/12/10 21:52 by tstarling