php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45182 substr UTF-8 character problem
Submitted: 2008-06-04 19:16 UTC Modified: 2008-06-05 16:05 UTC
From: bahadir at eggdrop dot gen dot tr Assigned:
Status: Not a bug Package: *Unicode Issues
PHP Version: 5.2.6 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: bahadir at eggdrop dot gen dot tr
New email:
PHP Version: OS:

 

 [2008-06-04 19:16 UTC] bahadir at eggdrop dot gen dot tr
Description:
------------
Hi there,

I have this function ...

If character start with > ?

Problem this:

Actual result: ?. Bahadir Kocaoglu

Expected result: ?. Bahadir Kocaoglu

Original string: ?mit Bahadir Kocaoglu

Reproduce code:
---------------
<?
function showMemberName($id) {
	$SQL = mysql_query(sprintf("SELECT `username`, `name` FROM `members` WHERE `id` = '%d';", $id));
	$Member = mysql_fetch_array($SQL);
	if ($Member[0]) {
		return $Member[0];
	} else {
		return substr($Member[1], 0, 1).'. '.strstr($Member[1], " ");
	}
	mysql_free_result($SQL);
}

echo showMemberName(1);
?>


Expected result:
----------------
?. Bahadir Kocaoglu


Actual result:
--------------
?. Bahadir Kocaoglu


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-06-05 16:05 UTC] jani@php.net
Unicode support comes with PHP 6. Use mbstring for now.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Oct 27 16:01:27 2024 UTC