php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65117 problem in returning
Submitted: 2013-06-25 06:16 UTC Modified: 2013-06-25 06:55 UTC
From: afarahmand1992 at gmail dot com Assigned:
Status: Not a bug Package: *Unicode Issues
PHP Version: 5.4Git-2013-06-25 (Git) OS: Windows
Private report: No CVE-ID: None
 [2013-06-25 06:16 UTC] afarahmand1992 at gmail dot com
Description:
------------
Hi
As you know , ANSI string length is equal to each character,
But in Unicode string (UTF-8) each character returns twice!
And for checking string that can be ANSI or UTF-8 we can't get the real 
length using strlen() !

What should we do?
I think it had better improve the strlen() function to check
the Unicode/ANSI String before return the length 


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-06-25 06:23 UTC] rasmus@php.net
-Status: Open +Status: Not a bug
 [2013-06-25 06:23 UTC] rasmus@php.net
See mb_strlen()
 [2013-06-25 06:28 UTC] afarahmand1992 at gmail dot com
thank you Rasmus
This is my issue 
And I can't believe that "You" answered me :)
 [2013-06-25 06:33 UTC] afarahmand1992 at gmail dot com
Oh it makes no different !

echo mb_strlen('A');
// returns 1

echo mb_strlen('ب');
//returns 2
 [2013-06-25 06:52 UTC] rasmus@php.net
You have to specify the correct encoding. eg.

mb_internal_encoding("UTF-8");
echo mb_strlen('ﺏ');
 [2013-06-25 06:55 UTC] afarahmand1992 at gmail dot com
Thank you sir.
All correct :)
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Nov 05 23:01:28 2024 UTC