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
 [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 08:01:29 2024 UTC