php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47150 substr() don't work sometimes
Submitted: 2009-01-19 16:55 UTC Modified: 2009-01-19 17:12 UTC
From: info at thierry-roussel dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.2.8 OS: Linux 2.6.24.
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: info at thierry-roussel dot com
New email:
PHP Version: OS:

 

 [2009-01-19 16:55 UTC] info at thierry-roussel dot com
Description:
------------
we have a probleme on production server with php 5.2.6
And the server administrator want to update on the 5.2.8 only if this bug is resolve in this version.

Sometimes, substr don't work and sometimes it does

The bug come only when there ist a specialchar like é or è.

we work in iso.

it is a production server with many client, so the administrator will not use the cvs version.

Thanks

Reproduce code:
---------------
<?php
echo htmlentities(substr(html_entity_decode("&eacute;abcde"),0,3))."<br>";
?>

Expected result:
----------------
éab

Actual result:
--------------
sometimes : éab

sometimes : éabcde



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-01-19 17:12 UTC] scottmac@php.net
Sounds like you're using UTF-8, and substr is designed to work on bytes rather than whole characters.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 27 12:01:29 2024 UTC