[PHP-BUG] Bug #51385 [NEW]: htmlentities next substr with UTF-8

[email protected] ("baudav at gmail dot com")
Newsgroups php.bugs
Message-ID <[email protected]>
From:             
Operating system: Windows 2003
PHP version:      5.3.2
Package:          *Unicode Issues
Bug Type:         Bug
Bug description:htmlentities next substr with UTF-8

Description:
------------
substr not truncate UTF-8 correctly, and generate bad UTF-8 string.

test script must be writen in UTF-8

Test script:
---------------
<?php
$str = 'câble TOSLink mâle/mâle (1.5 à 25m)';
$etc = '...';

echo htmlentities(substr($str, 0, 33). $etc, ENT_QUOTES, 'UTF-8')

?>

Expected result:
----------------
câble TOSLink mâle/mâle (1.5 ...

Actual result:
--------------
no return, just PHP error logged: 

PHP Warning:  htmlentities(): Invalid multibyte sequence in argument in
C:\DATA\WWW\test.php on line 5

change substr($str, 0, 33) by substr($str, 0, 32), it's work

-- 
Edit bug report at http://bugs.php.net/bug.php?id=51385&edit=1
-- 
Try a snapshot (PHP 5.2):            http://bugs.php.net/fix.php?id=51385&r=trysnapshot52
Try a snapshot (PHP 5.3):            http://bugs.php.net/fix.php?id=51385&r=trysnapshot53
Try a snapshot (PHP 6.0):            http://bugs.php.net/fix.php?id=51385&r=trysnapshot60
Fixed in SVN:                        http://bugs.php.net/fix.php?id=51385&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51385&r=needdocs
Fixed in release:                    http://bugs.php.net/fix.php?id=51385&r=alreadyfixed
Need backtrace:                      http://bugs.php.net/fix.php?id=51385&r=needtrace
Need Reproduce Script:               http://bugs.php.net/fix.php?id=51385&r=needscript
Try newer version:                   http://bugs.php.net/fix.php?id=51385&r=oldversion
Not developer issue:                 http://bugs.php.net/fix.php?id=51385&r=support
Expected behavior:                   http://bugs.php.net/fix.php?id=51385&r=notwrong
Not enough info:                     http://bugs.php.net/fix.php?id=51385&r=notenoughinfo
Submitted twice:                     http://bugs.php.net/fix.php?id=51385&r=submittedtwice
register_globals:                    http://bugs.php.net/fix.php?id=51385&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=51385&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=51385&r=dst
IIS Stability:                       http://bugs.php.net/fix.php?id=51385&r=isapi
Install GNU Sed:                     http://bugs.php.net/fix.php?id=51385&r=gnused
Floating point limitations:          http://bugs.php.net/fix.php?id=51385&r=float
No Zend Extensions:                  http://bugs.php.net/fix.php?id=51385&r=nozend
MySQL Configuration Error:           http://bugs.php.net/fix.php?id=51385&r=mysqlcfg
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.