[TYPO3-dev] String Handling in Extensions

Ries van Twisk typo3 at rvt.dds.nl
Thu Apr 12 22:31:46 CEST 2007


>
> "Ries van Twisk" <typo3 at rvt.dds.nl> schrieb im Newsbeitrag
> news:mailman.139617.1176404290.21067.typo3-dev at lists.netfielders.de...
>> hey Steffen,
>>
>> as soon as you work with other locales that can be multi-byte
>> then you should use these functions.
>> This is also true for values that come from posts/get's
>> when the website was set to multu-byte like utf-8.
>>
>> Ries
>>
>
> Hi Ries,
>
> you're right. So if the extension should work with all multibyte  
> langs. it
> should only use this functions.
> But i've not seen them used in extionsions before. Does this means  
> an ext
> like tt_news gets in trouble on a chinese page ?
Yes :)

Personally I don't use them much myself...
One solution what chinese people could do is
map the mb version to the single byte versions
and they are good again.. properly they have done that by default?!?!

Even core doesn't do it correct, since I had a template in Estonia  
language
that was not parsed correctly and it happend to be
down the line that one of the string functions went 'haywire'.

The good/bad thing is that errors don't happen to often thank
to the smart guys of unicode.com that created utf-8.

However since errors are hard to detect (can you read chinese??)
it's also hard to debug and unfortunately PHP 'thinks' latin1.

So in short, extensions might get into trouble,
they don't have to get in trouble.

For example concate functions like . will goes likly ok.
strlen can and will go wrong and returns the incorrect
number of characters (strlen returns bytes).

Other functions like strpos() might go wrong,
but you can use strpos to find a chinese character
if you like, but think binary!!!

typo3 tries to solve it with the locale class,
I used it a couple of times where I knew
it could go wrong.... But like you and many other
we don't use them often enough!!!


Ries






>
> vg  Steffen
>
>> On Apr 12, 2007, at 1:36 PM, Steffen Kamper wrote:
>>
>>>
>>> "Ingo Renner" <typo3 at ingo-renner.com> schrieb im Newsbeitrag
>>> news:mailman.1.1176402192.13172.typo3-dev at lists.netfielders.de...
>>>> Steffen Kamper wrote:
>>>>
>>>>> I looked in the core for an universal method, but didn't found a
>>>>> strict
>>>>> rule.
>>>>> How should this be done ? mb-functions are not available on all
>>>>> systems,
>>>>> and there is a flag in installtool, iconv also, ...
>>>>
>>>> AFAIR there're some methods in csConv ...
>>>>
>>>> Ingo
>>>
>>> Hi Ingo,
>>>
>>> good hint, ty  - i didn't realized before.
>>> There are functions in t3lib_cs like
>>> substr
>>> strlen
>>> crop
>>> etc.
>>>
>>> So every input string should be handled with tis methods to be sure.
>>> Additional question: Are the form values has to be handled same  
>>> way ?
>>>
>>> vg Steffen
>>>
>>>
>>> _______________________________________________
>>> TYPO3-dev mailing list
>>> TYPO3-dev at lists.netfielders.de
>>> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev
>>
>> -- 
>> Ries van Twisk
>> Freelance Typo3 Developer
>> email: ries at vantwisk.nl
>> web:   http://www.rvantwisk.nl/
>> skype: callto://r.vantwisk
>>
>>
>>
>>
>
>
> _______________________________________________
> TYPO3-dev mailing list
> TYPO3-dev at lists.netfielders.de
> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev

-- 
Ries van Twisk
Freelance Typo3 Developer
email: ries at vantwisk.nl
web:   http://www.rvantwisk.nl/
skype: callto://r.vantwisk








More information about the TYPO3-dev mailing list