mb_strcut.phpt 756 B

12345678910111213141516171819202122232425262728293031323334
  1. --TEST--
  2. mb_strcut()
  3. --SKIPIF--
  4. <?php extension_loaded('mbstring') or die('skip mbstring not available'); ?>
  5. --INI--
  6. output_handler=
  7. --FILE--
  8. <?php
  9. // TODO: Add more encodings
  10. ini_set('include_path', dirname(__FILE__));
  11. include_once('common.inc');
  12. // EUC-JP
  13. $euc_jp = '0123この文字列は日本語です。EUC-JPを使っています。日本語は面倒臭い。';
  14. print mb_strcut($euc_jp, 6, 5,'EUC-JP') . "\n";
  15. print mb_strcut($euc_jp, 0, 100,'EUC-JP') . "\n";
  16. $str = mb_strcut($euc_jp, 100, 10,'EUC-JP');
  17. ($str === false) ? print "OK\n" : print "NG: $str\n";
  18. $str = mb_strcut($euc_jp, -100, 10,'EUC-JP');
  19. ($str !== "") ? print "OK: $str\n" : print "NG:\n";
  20. ?>
  21. --EXPECT--
  22. の文
  23. 0123この文字列は日本語です。EUC-JPを使っています。日本語は面倒臭い。
  24. OK
  25. OK: 0123この文