mb_convert_case (Was: Re: #19257 [Bgs]: strtolower & strtoupper does not work for UTF-8 strings)
| From: | Wez Furlong | Date: | Thu, 26 Sep 2002 01:10:04 +0000 |
| Subject: | mb_convert_case (Was: Re: #19257 [Bgs]: strtolower & strtoupper does not work for UTF-8 strings) | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-88614@lists.php.net to get a copy of this message | ||
All:
I've just committed a php-style version of the ucdata package that Stig
directed me to.
usage:
proto string mb_convert_case(string str, int mode [, string encoding]);
mode can be one of MB_CASE_UPPER, MB_CASE_LOWER or MB_CASE_TITLE.
encoding specifies the encoding of str; if omitted, the
mbstring.internal_encoding value will be used.
The return value is str with the appropriate case folding applied.
The function works by internally converting the string into UCS-4 format
and applying php_unicode_to(upper|lower|title) to each unicode character,
and then converts the string back into the original encoding.
Stig:
Rather than generate binary data files at configure time, based on
a bundled UnicodeData.txt file which is quite large, causes problems
for win32 builds, and has run-time thread safety and data file location
issues (for freshly built but not installed php binaries), I settled on
having ucgendat generate a header file with the ctype and case data tables
declared within it.
All that is needed is to add these files to the build and voila! it works :-)
Yasuo:
I know that there is development going on on sf.net; to save problems with
merging I've tried to keep as much of this new code separate from existing
files as possible, and also to keep the changes to mbstring.c to a minimum.
There are some interesting functions available in the ucdata package; some
of them might benefit mbstring, so perhaps it is worth a look?
--Wez.