Bug #69179 [Opn->Nab]: The problem is in string length with RTL languages

From: Date: Wed, 04 Mar 2015 08:39:02 +0000
Subject: Bug #69179 [Opn->Nab]: The problem is in string length with RTL languages
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-191127@lists.php.net to get a copy of this message
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)

« previous php.bugs (#191127) next »