Re: mb_ereg_replace problem with non a-z characters

Moriyoshi Koizumi <[email protected]>
Newsgroups gmane.comp.php.internationalization
Message-ID <[email protected]>
Hi,

On 2005/01/18, at 0:55, McAjvar wrote:

> i hope this is the right group for my question, if i got it wrong, 
> please accept my apologies and tell me where to go next.

I think this is the right list, while it isn't really active :)

> ereg_replace ("[^[:alnum:]\n]", "", $t)
>
> all japanese, russian, etc. characters remain in the string, as i'd 
> like them to.
>
> but when i test this same function on dragonflybsd or freebsd, all 
> those characters get stripped out.
>
> php.ini settings, mbstring section has the overload setting set to 
> overload everything, so php should basically be using mb_ereg_replace. 
> just to be sure, i tried that function specifically.

There are three possibilities:
a. Function overloading doesn't work at all on those platforms
    for an unknown reason.

    Reportedly the plain ereg_replace() malfunctions with UTF-8.

b. You are running FreeBSD on a 64 bit architecture and
    mb_ereg_replace() doesn't behave well with it.

    Recently some 64bit related bugs were addressed in mbstring,
    and there are probably ones missed still.

c. BSD's libc implementation is borked and inproperly handles
    the argument of isalnum().


To confirm those, please try the following steps:

1. Replace every ereg_replace() by mb_ereg_replace() and then run it 
through.

2. Run the one-liner below on a shell prompt and include the outout in 
the reply
    to this mail:

( echo "#include <stdio.h>"; echo "#include <ctype.h>"; echo 'main() { 
int i; for (i = 0; i < 256; i++) { printf("%d", isalnum(i) ? 1: 0); } 
printf("\n"); }' ) > /var/tmp/test.c && gcc -o /var/tmp/test 
/var/tmp/test.c && /var/tmp/test && rm /var/tmp/test.c /var/tmp/test

> my test environments are:
> win2k, sp4, apache 2.0.50, php 4.3.8 (here, it works ok)
> freebsd 5.2.1, fully patched, apache-1.3.31_4, mod_php4-4.3.8_2,1 
> (doesn't work)
> dragonflybsd, latest version, today freshly installed apache and php 
> from ports, also doesn't work

BTW,

> mbstring.language = Neutral
> mbstring.internal_encoding = UTF-8
> mbstring.http_input = UTF-8
> mbstring.http_output = UTF-8
> mbstring.encoding_translation = On
> mbstring.substitute_character = _
> mbstring.func_overload = 7

If http_input equals to internal_encoding then you don't need to turn
on encoding_translation.

Moriyoshi

-- 
PHP Internationalization Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.