Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 1.3.1

Request #7014 Multi-byte strlen() improvement
Submitted: 2006-03-04 12:35 UTC
From: koto at webworkers dot pl Assigned: yunosh
Status: Closed Package: Console_Table (version 1.0.2)
PHP Version: Irrelevant OS: win
Roadmaps: (Not assigned)    
Subscription  


 [2006-03-04 12:35 UTC] koto at webworkers dot pl (koto)
Description: ------------ Current stable release 1.0.2 does not support multi-byte characters which results in invalid column-length calculations for UTF-8 strings. As I can see, the CVS version already addresses this issue by providing setCharset() function and using mb_string() function. This hovewer limits possible usage to PHP users that have multibyte extension compiled in, which is not so common in shared config environments. The solution for those not having multibyte extension would be to use the following snippet: ( found @ http://pl.php.net/manual/en/function.strlen.php#45407 ) $length = strlen(utf8_decode($s)); utf8_decode() converts characters that are not in ISO-8859-1 to '?', which, for the purpose of counting, is quite alright. I propose adding the function as a fallback method to the _strlen() function in CVS version, so instead of: return strlen($str); we do: return strlen(utf8_decode($str));

Comments

 [2006-03-04 16:14 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2006-03-12 23:34 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!