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
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: jrs at bluekiwi-software dot com
New email:
PHP Version: OS:

 

 [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

Add a Patch

Pull Requests

Add a Pull Request

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-2020 The PHP Group
All rights reserved.
Last updated: Fri Aug 14 20:01:24 2020 UTC