4.3.0RC2 preg_match() messing up UTF-8

From: Date: Tue, 10 Dec 2002 03:15:23 +0000
Subject: 4.3.0RC2 preg_match() messing up UTF-8
Groups: php.qa 
Request: Send a blank email to php-qa+get-7154@lists.php.net to get a copy of this message
I have problem with preg_match() messingup the end of a string, on a particular match pattern. Btw, I've used UTF-8 for this message, so I can show the actual string. In the code attached below, the third param that I'm grabbing is being messed up; the 'ê' character, does not come out properly, and what follows, is simply truncated. Using a hex editor I compared the output from the one that works and the one that doesn't, and I found out that the character which is 0xC3AA, is truncated to 0xC3 and everything after it is gone. This is all on a linux machine, with apache 2.0.43, and glibc 2.2.2 (if relevant). I've compiled PHP with mbstring support, and I've set the mbstring.internal_encoding to "UTF-8". <?php header('Content-Type: text/plain; charset=UTF-8'); $ss = 'U+356D kVietnamese êu'; /* following screws up */ $r = preg_match('/^(U.+?)\t(.+?)\t(.+?)/', $ss, $cap); /* a small change in the matching pattern and it works */ //$r = preg_match('/^(U.+?)\t(.+?)\t(.+)/', $ss, $cap); echo "$cap[0]\n"; echo "$ss\n"; return; ?>

« previous php.qa (#7154) next »