php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #69179 The problem is in string length with RTL languages
Submitted: 2015-03-04 07:53 UTC Modified: 2015-03-04 08:39 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: rm dot nasir at hotmail dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 5.5Git-2015-03-04 (snap) OS: Windows 8.1 Enterprise 32bit
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
14 + 16 = ?
Subscribe to this entry?

 
 [2015-03-04 07:53 UTC] rm dot nasir at hotmail dot com
Description:
------------
Hi!

I got a problem with my PHP 5.5.12 which I got with WAMP Server.

PROBLEM:
  When I want to return the length of an Arabic string value it is not showing the exact length of the characters I wrote in that string PHP is increasing the length.

Test script:
---------------
header('Content-Type: text/html; charset=utf-8;');

// demo string by Pashto language
$myText = "دا يوه جمله ده";

// length of the string above is 14 characters
// you can test it with JavaScript in your browser console
// and that is returning the exact length 14 but in PHP
// it is showing 25

echo strlen( $myText ); // 25

// I also tested it with

var_dump( $myText ); // string 'دا يوه جمله ده' (length=25)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-03-04 08:39 UTC] ab@php.net
-Status: Open +Status: Not a bug
 [2015-03-04 08:39 UTC] ab@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Thanks for reporting. strlen() is not multibyte aware, it delivers the count of bytes, not characters. What you do need is probably mb_strlen(), iconv_strlen() or alike with regard to the correct charset settings.

Cheers.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 06:01:29 2024 UTC