PageRenderTime 44ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/system/core/utf8/strlen.php

https://github.com/shodanuk/Toodle
PHP | 21 lines | 9 code | 2 blank | 10 comment | 2 complexity | 3cb07d485c796d0926d9c5367eb97958 MD5 | raw file
  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. }