mb_strwidth.phpt 868 B

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