[TYPO3-core] RFC: Fix Bug 6428 - strtoupper doesn't work with turkish i
Martin Kutschker
Martin.Kutschker at n0spam-blackbox.net
Mon Oct 29 11:04:22 CET 2007
Steffen Kamper schrieb:
> "Steffen Kamper" <steffen at sk-typo3.de> schrieb im Newsbeitrag
> news:mailman.1.1193574840.31071.typo3-team-core at lists.netfielders.de...
>> "Ernesto Baschny [cron IT]" <ernst at cron-it.de> schrieb im Newsbeitrag
>> news:mailman.1.1193570491.28448.typo3-team-core at lists.netfielders.de...
>>
>>> A nice idea would be to have a t3lib_div::asciiToUpper($string) method
>>> which will only handle 7bit characters but will ignore current locale
>>> (doing tr/a..z/A..Z/ for example). I think there are many extensions
>>> which do a strtoupper for internal purposes without thinking about the
>>> implication with other locales. Even I didn't know about that
>>> restriction in turkish. I thought a-z was "alphabetic" characters in all
>>> languages. :)
>>>
>>> Cheers,
>>> Ernesto
>> indeed that would be the best solution. I start to try this but was
>> unlucky for now.
>>
>> btw - in php6 this will be corrected, but not for php5:
>> http://bugs.php.net/bug.php?id=42063
>>
>> vg Steffen
>>
>
> any comments on using a function like that?
>
> function asciiToCase($string,$case) {
> if($GLOBALS['TSFE']->tmpl->setup['config.']['locale_all']) {
> $tmp=$GLOBALS['TSFE']->tmpl->setup['config.']['locale_all'];
> setlocale(LC_CTYPE,'en');
> $caseString=$case=='upper' ? strtoupper($string) : strtolower($string);
> setlocale(LC_CTYPE,$tmp);
> } else
> $caseString=$case=='upper' ? strtoupper($string) : strtolower($string);
> return $caseString;
> }
setlocale() is per process and not per thread, so we cannot use it easily
(see PHP docs).
But we can as has been suggested use strtr($str, 'abc...xyz', 'ABC...XYZ');
Masi
More information about the TYPO3-team-core
mailing list