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
 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2020 The PHP Group
All rights reserved.
Last updated: Wed Jan 22 13:01:23 2020 UTC