Re: utf-8-safe replacement for strtr()?
| From: | Tom Worster | Date: | Fri, 27 Mar 2009 15:05:55 +0000 |
| Subject: | Re: utf-8-safe replacement for strtr()? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-290761@lists.php.net to get a copy of this message | ||
On 3/26/09 11:36 AM, "Nisse Engström" <news.NOSPAM.0ixbtqKe@luden.se> wrote:
> On Wed, 25 Mar 2009 11:32:42 +0100, Nisse Engström wrote:
>
>> On Tue, 24 Mar 2009 08:15:35 -0400, Tom Worster wrote:
>>
>>> strtr() with three parameters is certainly unsafe. but my tests are showing
>>> that it may be ok with two parameters if the strings in the second parameter
>>> are well formed utf-8.
>>>
>>> does anyone know more? can confirm or contradict?
>>
>> The two-argument version of strtr() should work fine
>> since there are no collisions in utf-8 such that part
>> of one character matches part of a different character.
>
> Oops. I meant to write that one complete character does
> not match any part of any other character. If a string
> of one or more utf-8 characters match a utf-8 text, it
> matches exactly those characters in the text. If that
> makes sense...
yes.
my conclusion is that 2-param strtr is safe if the subject text and
parameter strings are valid utf-8.