From:             
Operating system: Windows XP prof. V2002 with SP3
PHP version:      5.3.8
Package:          PCRE related
Bug Type:         Bug
Bug description:PCRE functions and encoding UTF-8

Description:
------------
Hi!

My HTML source I write in the encoding UTF-8 and I have probably found a
bug (... soon cost me two hours of searching and working for a flaw in my
logic).

And indeed, I want with preg_match() a string to check for valid characters
and simultaneously for a minimum length. In the string should german
special characters (Ä, Ö, Ü, ß) also be allowed. As I noted, these are
all PCRE functions treated as two letters, if the encoding is UTF-8.
Examples see below.

For tips on how I can work around this problem, I would be grateful.

greeting
Ki-Bi

Test script:
---------------
/*
   remark:
   The source is saved with encoding UTF-8 (without BOM)
*/
$animal = 'Bär';
if (preg_match('~^[a-zäöüß\.\- ]{4,26}$~i', $animal)){
                echo "$animal has a word length from 4 to 26 letters.\n";
        }else{
                echo "$animal is too short or too long!\n";}
$string = 'Dörte hütet die Schäfchen und trinkt dabei ein Maß Bier.
Ärger gibt es dabei nicht.';
echo preg_replace('~[äöüß]~i', '*', $string);

Expected result:
----------------
Bär has a word length from 4 to 26 letters.
D**rte h**tet die Sch**fchen und trinkt dabei ein Ma** Bier. *�rger gibt
es dabei nicht.


-- 
Edit bug report at https://bugs.php.net/bug.php?id=60603&edit=1
-- 
Try a snapshot (PHP 5.4):            
https://bugs.php.net/fix.php?id=60603&r=trysnapshot54
Try a snapshot (PHP 5.3):            
https://bugs.php.net/fix.php?id=60603&r=trysnapshot53
Try a snapshot (trunk):              
https://bugs.php.net/fix.php?id=60603&r=trysnapshottrunk
Fixed in SVN:                        
https://bugs.php.net/fix.php?id=60603&r=fixed
Fixed in SVN and need be documented: 
https://bugs.php.net/fix.php?id=60603&r=needdocs
Fixed in release:                    
https://bugs.php.net/fix.php?id=60603&r=alreadyfixed
Need backtrace:                      
https://bugs.php.net/fix.php?id=60603&r=needtrace
Need Reproduce Script:               
https://bugs.php.net/fix.php?id=60603&r=needscript
Try newer version:                   
https://bugs.php.net/fix.php?id=60603&r=oldversion
Not developer issue:                 
https://bugs.php.net/fix.php?id=60603&r=support
Expected behavior:                   
https://bugs.php.net/fix.php?id=60603&r=notwrong
Not enough info:                     
https://bugs.php.net/fix.php?id=60603&r=notenoughinfo
Submitted twice:                     
https://bugs.php.net/fix.php?id=60603&r=submittedtwice
register_globals:                    
https://bugs.php.net/fix.php?id=60603&r=globals
PHP 4 support discontinued:          
https://bugs.php.net/fix.php?id=60603&r=php4
Daylight Savings:                    https://bugs.php.net/fix.php?id=60603&r=dst
IIS Stability:                       
https://bugs.php.net/fix.php?id=60603&r=isapi
Install GNU Sed:                     
https://bugs.php.net/fix.php?id=60603&r=gnused
Floating point limitations:          
https://bugs.php.net/fix.php?id=60603&r=float
No Zend Extensions:                  
https://bugs.php.net/fix.php?id=60603&r=nozend
MySQL Configuration Error:           
https://bugs.php.net/fix.php?id=60603&r=mysqlcfg

Reply via email to