Bug #69179 [Opn->Nab]: The problem is in string length with RTL languages
Edit report at https://bugs.php.net/bug.php?id=69179&edit=1
ID: 69179
Updated by: ab@php.net
Reported by: rm dot nasir at hotmail dot com
Summary: The problem is in string length with RTL languages
-Status: Open
+Status: Not a bug
Type: Bug
Package: Strings related
Operating System: Windows 8.1 Enterprise 32bit
PHP Version: 5.5Git-2015-03-04 (snap)
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[2015-03-04 07:53:27] 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)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=69179&edit=1
Thread (2 messages)