|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2011-05-08 17:00 UTC] g dot huebgen at arcor dot de
Description: ------------ --- From manual page: http://www.php.net/function.stripos#Description --- If some text is encoded in UTF-8 and I search this text with stripos for a string with (e.g.) lower case Umlaut (e.g. ü), this function does not find the upper-case Umlaut (Ü). That means case-insensitive does not work for Umlauts if a text file is encoded UTF-8. Test script: --------------- File test.txt contains "Übermut" and is encoded UTF-8 without BOM <?php $text = file_get_contents("test.txt"); echo $text."<br>"; $str = "über"; if (($pos=stripos($text,$str)) !== false) echo $str." gefunden"; else echo $str." nicht gefunden"; ?> Expected result: ---------------- Übermut über gefunden Actual result: -------------- Übermut über nicht gefunden PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Dec 14 05:00:01 2025 UTC |
Hi rasmus. Now I tried mb_stripos but the result is not different to stripos. The same program but using mb_stripos: $text = file_get_contents("test-utf8.txt"); $str = "über"; if (($pos=mb_stripos($text,$str)) !== false) echo $str." found"; else echo $str." not found"; output is: not found! If I use utf8_decode for both $text and $str then stripos will work properly.Well, somewhere along the way you have messed up your encoding since it works fine when both strings are UTF-8: var_dump(mb_stripos("Übermut","über",0,"UTF-8")); Are you saying that this doesn't give you int(0) on your platform?