PageRenderTime 86ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/includes/libraries/utf8/strlen.php

http://joostina.googlecode.com/
PHP | 21 lines | 9 code | 2 blank | 10 comment | 2 complexity | 3cb07d485c796d0926d9c5367eb97958 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php defined('SYSPATH') OR die('No direct access allowed.');
  2. /**
  3. * utf8::strlen
  4. *
  5. * @package Core
  6. * @author Kohana Team
  7. * @copyright (c) 2007 Kohana Team
  8. * @copyright (c) 2005 Harry Fuecks
  9. * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
  10. */
  11. function _strlen($str)
  12. {
  13. // Try mb_strlen() first because it's faster than combination of is_ascii() and strlen()
  14. if (SERVER_UTF8)
  15. return mb_strlen($str);
  16. if (utf8::is_ascii($str))
  17. return strlen($str);
  18. return strlen(utf8_decode($str));
  19. }