php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54148 substr does not return correct substring
Submitted: 2011-03-03 12:07 UTC Modified: 2011-03-03 13:20 UTC
From: jrs at bluekiwi-software dot com Assigned:
Status: Not a bug Package: *Unicode Issues
PHP Version: 5.3.5 OS: Windows 7
Private report: No CVE-ID: None
 [2011-03-03 12:07 UTC] jrs at bluekiwi-software dot com
Description:
------------
---
From manual page: http://www.php.net/function.mb-substr#Return Values
---

tested with korean caracters.

Test script:
---------------
header('Content-Type: text/html; charset=UTF-8');
$var = '무료서버 이용자입니다';
var_dump($var);
echo "<br />";
$var = mb_substr($var, 0, 2);
var_dump($var);

Expected result:
----------------
무료서버 이용자입니다
무료

Actual result:
--------------
무료서버 이용자입니다
�

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-03-03 13:20 UTC] dtajchreber@php.net
-Status: Open +Status: Bogus
 [2011-03-03 13:20 UTC] dtajchreber@php.net
david@copenhagen:~/test$ /home/david/dev/php/php53/sapi/cli/php -v
PHP 5.3.6-dev (cli) (built: Feb 26 2011 23:29:38) (DEBUG)
Copyright (c) 1997-2011 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2011 Zend Technologies
david@copenhagen:~/test$ /home/david/dev/php/php53/sapi/cli/php t.php 
string(31) "무료서버 이용자입니다"
string(6) "무료"
david@copenhagen:~/test$ cat t.php 
<?php

$var = '무료서버 이용자입니다';
var_dump($var);
$var = mb_substr($var, 0, 2, 'utf-8');
var_dump($var);

david@copenhagen:~/test$
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 12:01:31 2024 UTC