iconv_strlen_basic.phpt 962 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. --TEST--
  2. Test iconv_strlen() function : basic functionality
  3. --SKIPIF--
  4. <?php
  5. extension_loaded('iconv') or die('skip');
  6. function_exists('iconv_strlen') or die("skip iconv_strlen() is not available in this build");
  7. ?>
  8. --FILE--
  9. <?php
  10. /* Prototype : int iconv_strlen(string str [, string charset])
  11. * Description: Get character numbers of a string
  12. * Source code: ext/iconv/iconv.c
  13. */
  14. /*
  15. * Test basic functionality of iconv_strlen()
  16. */
  17. echo "*** Testing iconv_strlen() : basic functionality***\n";
  18. $string_ascii = b'abc def';
  19. //Japanese string in UTF-8
  20. $string_mb = base64_decode(b'5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCMDEyMzTvvJXvvJbvvJfvvJjvvJnjgII=');
  21. echo "\n-- ASCII String --\n";
  22. var_dump(iconv_strlen($string_ascii));
  23. echo "\n-- Multibyte String --\n";
  24. var_dump(iconv_strlen($string_mb, 'UTF-8'));
  25. ?>
  26. ===DONE===
  27. --EXPECTF--
  28. *** Testing iconv_strlen() : basic functionality***
  29. -- ASCII String --
  30. int(7)
  31. -- Multibyte String --
  32. int(21)
  33. ===DONE===