php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17298 stristr is not case-insensitive with scandinavian alphabets
Submitted: 2002-05-17 18:04 UTC Modified: 2002-05-17 18:51 UTC
From: hannu dot maksimainen at edu dot hel dot fi Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.2.0 OS: linux 2.4.18
Private report: No CVE-ID: None
 [2002-05-17 18:04 UTC] hannu dot maksimainen at edu dot hel dot fi
I have a string "There are ? and ? in scandinavian alphabets".

I want stristr function to return everything after the first occurence of "?" (capital ? in this case) in my script:

$str = "There are ? and ? in scandinavian alphabets";
echo stristr($str, "?");

It returns "? in scandinavian alphabets".
It should return "? and ? in scandinavian alphabets".

--
With 'normal' alphabets it works ok. Like this:

$str = "There are B and b in scandinavian alphabets";
echo stristr($str, "b");

and it returns "B and b in scandinavian alphabets"

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-17 18:13 UTC] sniper@php.net
I can't reproduce this..it might be some locale issue.
Which linux distro?

--Jani

 [2002-05-17 18:40 UTC] hannu dot maksimainen at edu dot hel dot fi
Mandrake 7.2 with kernel 2.4.18
apache 2.0.35
php 4.2.0

I also tested this with my friend's server and it didn't work there either. He has Debian Linux (2.4.16 kernel) with apache 1.3.23 and php 4.1.2.
 [2002-05-17 18:51 UTC] sniper@php.net
It's really a locale issue. Not PHP problem in, you just need to set the locale correctly.

Either via environment var LC_ALL or setting it in the script with setlocale(), e.g.:

setlocale(LC_ALL, "fi_FI");

--Jani

 [2002-05-17 19:01 UTC] hannu dot maksimainen at edu dot hel dot fi
That fixed the problem.

To be more specific, it is enough to write setlocale(LC_CTYPE, "fi_FI") in this case.

"LC_CTYPE for character classification and conversion"

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 14:01:32 2024 UTC