Support Joomla!

Joomla! 1.5 Documentation

Packages

Package: utf8

Developer Network License

The Joomla! Developer Network content is © copyright 2006 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution- NonCommercial- ShareAlike 2.5
Source code for file /phputf8/native/strlen.php

Documentation is available at strlen.php

  1. <?php
  2. /**
  3. @version $Id: strlen.php,v 1.4 2006/02/26 23:59:50 harryf Exp $
  4. @package utf8
  5. @subpackage strings
  6. */
  7.  
  8. /**
  9. * Define UTF8_STRLEN as required
  10. */
  11. if !defined('UTF8_STRLEN') ) {
  12.     define('UTF8_STRLEN',TRUE);
  13. }
  14.  
  15. //--------------------------------------------------------------------
  16. /**
  17. * Unicode aware replacement for strlen(). Returns the number
  18. * of characters in the string (not the number of bytes), replacing
  19. * multibyte characters with a single byte equivalent
  20. * utf8_decode() converts characters that are not in ISO-8859-1
  21. * to '?', which, for the purpose of counting, is alright - It's
  22. * much faster than iconv_strlen
  23. * Note: this function does not count bad UTF-8 bytes in the string
  24. * - these are simply ignored
  25. @author <chernyshevsky at hotmail dot com>
  26. @link   http://www.php.net/manual/en/function.strlen.php
  27. @link   http://www.php.net/manual/en/function.utf8-decode.php
  28. @param string UTF-8 string
  29. @return int number of UTF-8 characters in string
  30. @package utf8
  31. @subpackage strings
  32. */
  33. function utf8_strlen($str){
  34.     return strlen(utf8_decode($str));
  35. }

Documentation generated on Mon, 05 Mar 2007 21:27:18 +0000 by phpDocumentor 1.3.1