php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #35520 Functioncs substr, str_replace, strtr and other do not work with UTF-8 string
Submitted: 2005-12-02 12:18 UTC Modified: 2005-12-02 12:24 UTC
Votes:7
Avg. Score:4.4 ± 0.7
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:1 (20.0%)
From: kotysek at email dot cz Assigned:
Status: Wont fix Package: Strings related
PHP Version: 4.4.1 OS: Windows XP
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: kotysek at email dot cz
New email:
PHP Version: OS:

 

 [2005-12-02 12:18 UTC] kotysek at email dot cz
Description:
------------
If I try to use almost any string function on a string with non-ascii characters encoded in UTF-8 I get some messed up results.

This relates mainly to: substr, str_replace, strtr, strtolower, strtoupper, strlen, ...

My string: consists of czech, slovak, german, etc. chars like ? (č) , ň (ň) ? (ä) , ? (ö) ,...

I can't even use the most basic thing like below.

Reproduce code:
---------------
$string = "aa?"; // last character is special czech "c" (č) 
echo $string[2];

Expected result:
----------------
// the code should just print "?" (č)
?

Actual result:
--------------
// it prints some character (depends on the character following "?"
?

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2005-12-02 12:24 UTC] tony2001@php.net
This is the main reason for PHP6 to appear.
So you have to wait for it.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 19:01:31 2024 UTC