// TODO:
//$debug = true;
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// EUC-JP
$r = mb_internal_encoding('EUC-JP');
// TODO: This is not a real test.... Need to change so that it does real testing
//$debug = true;
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
$ini = ini_get('mbstring.http_input');
//TODO: Add more encoding. Wrong paramter type test.
//$debug = true;
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// Set HTTP output encoding to ASCII
$r = mb_http_output('ASCII');
<?php
//$debug = true;
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// Set order to "auto"
<?php
//$debug = true;
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// Note: It does not return TRUE/FALSE for setting char
print "== INVALID PARAMETER ==\n";
$r = mb_substitute_character('BAD_NAME');
($r === FALSE) ? print "OK_BAD_NAME\n" : print("NG_BAD_NAME: ".gettype($r)." $r\n");
-print mb_substitute_character() . "\n";
?>
OK_NONE
none
== INVALID PARAMETER ==
-ERR:
+ERR: Warning
OK_BAD_NAME
//$debug=true;
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
$str = mb_preferred_mime_name('sjis-win');
//$debug=true;
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// restore detect_order to 'auto'
mb_detect_order('auto');
// JIS
// Note: either convert_encoding or strlen has problem
echo "== JIS ==\n";
+mb_internal_encoding('EUC-JP') or print("mb_internal_encoding() failed\n");
$jis = mb_convert_encoding($euc_jp, 'JIS');
print mb_strlen($jis,'JIS') . "\n";
mb_internal_encoding('JIS') or print("mb_internal_encoding() failed\n");
// UTF-8
// Note: either convert_encoding or strlen has problem
echo "== UTF-8 ==\n";
+mb_internal_encoding('EUC-JP') or print("mb_internal_encoding() failed\n");
$utf8 = mb_convert_encoding($euc_jp, 'UTF-8');
print mb_strlen($utf8,'UTF-8') . "\n";
mb_internal_encoding('UTF-8') or print("mb_internal_encoding() failed\n");
//$debug=true;
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// Test string
// Note: PHP Warning - offset is negative.
// Note: For offset(-15). It does not return position of latter string. (ie the same result as -50)
echo "== NEGATIVE OFFSET ==\n";
-print mb_strpos($euc_jp,'ÆüËܸì', -15, 'EUC-JP') . "\n";
-print mb_strpos($euc_jp, '0', -15, 'EUC-JP') . "\n";
-print mb_strpos($euc_jp, 3, -15, 'EUC-JP') . "\n";
-print mb_strpos($euc_jp, 0, -15, 'EUC-JP') . "\n";
-print mb_strpos($euc_jp,'ÆüËܸì', -50, 'EUC-JP') . "\n";
-print mb_strpos($euc_jp, '0', -50, 'EUC-JP') . "\n";
-print mb_strpos($euc_jp, 3, -50, 'EUC-JP') . "\n";
-print mb_strpos($euc_jp, 0, -50, 'EUC-JP') . "\n";
+$r = mb_strpos($euc_jp,'ÆüËܸì', -15, 'EUC-JP');
+($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
+$r = mb_strpos($euc_jp, '0', -15, 'EUC-JP');
+($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
+$r = mb_strpos($euc_jp, 3, -15, 'EUC-JP');
+($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
+$r = mb_strpos($euc_jp, 0, -15, 'EUC-JP');
+($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
+$r = mb_strpos($euc_jp,'ÆüËܸì', -50, 'EUC-JP');
+($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
+$r = mb_strpos($euc_jp, '0', -50, 'EUC-JP');
+($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
+$r = mb_strpos($euc_jp, 3, -50, 'EUC-JP');
+($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
+$r = mb_strpos($euc_jp, 0, -50, 'EUC-JP');
+($r === FALSE) ? print "OK_NEGATIVE_OFFSET\n" : print "NG_NEGATIVE_OFFSET\n";
// Out of range - should return false
print ("== OUT OF RANGE ==\n");
-$r = mb_strpos($euc_jp,'ÆüËܸì', 40, 'EUC-JP') . "\n";
+$r = mb_strpos($euc_jp,'ÆüËܸì', 40, 'EUC-JP');
($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n";
-$r = mb_strpos($euc_jp, '0', 40, 'EUC-JP') . "\n";
+$r = mb_strpos($euc_jp, '0', 40, 'EUC-JP');
($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n";
-$r = mb_strpos($euc_jp, 3, 40, 'EUC-JP') . "\n";
+$r = mb_strpos($euc_jp, 3, 40, 'EUC-JP');
($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n";
-$r = mb_strpos($euc_jp, 0, 40, 'EUC-JP') . "\n";
+$r = mb_strpos($euc_jp, 0, 40, 'EUC-JP');
($r === FALSE) ? print "OK_OUT_RANGE\n" : print "NG_OUT_RANGE\n";
// Note: Returned NULL string
// echo gettype($r). ' val '. $r ."\n";
33
30
== NEGATIVE OFFSET ==
-34
-30
-33
-30
-10
-0
-3
-0
+ERR: Warning
+OK_NEGATIVE_OFFSET
+ERR: Warning
+OK_NEGATIVE_OFFSET
+ERR: Warning
+OK_NEGATIVE_OFFSET
+ERR: Warning
+OK_NEGATIVE_OFFSET
+ERR: Warning
+OK_NEGATIVE_OFFSET
+ERR: Warning
+OK_NEGATIVE_OFFSET
+ERR: Warning
+OK_NEGATIVE_OFFSET
+ERR: Warning
+OK_NEGATIVE_OFFSET
== OUT OF RANGE ==
OK_OUT_RANGE
OK_OUT_RANGE
//$debug=true;
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// Test string
<?php
// TODO: Add more encodings
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// EUC-JP
$euc_jp = '0123¤³¤Îʸ»úÎó¤ÏÆüËܸì¤Ç¤¹¡£EUC-JP¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡£ÆüËܸì¤ÏÌÌÅݽ¤¤¡£';
<?php
// TODO: Add more encodings
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// EUC-JP
$euc_jp = '0123¤³¤Îʸ»úÎó¤ÏÆüËܸì¤Ç¤¹¡£EUC-JP¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡£ÆüËܸì¤ÏÌÌÅݽ¤¤¡£';
// TODO: Add more encoding
//$debug = true;
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// EUC-JP
$euc_jp = '0123¤³¤Îʸ»úÎó¤ÏÆüËܸì¤Ç¤¹¡£EUC-JP¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡£ÆüËܸì¤ÏÌÌÅݽ¤¤¡£';
print "2: ". mb_strimwidth($euc_jp, 0, 100,'...','EUC-JP') . "\n";
print "3: ". mb_strimwidth($euc_jp, 15, 100,'...','EUC-JP') . "\n";
// Note: Did not start form -22 offset. Staring from 0.
-print "4: ". mb_strimwidth($euc_jp,-22, 100,'...','EUC-JP') . "\n";
+$str = mb_strimwidth($euc_jp,-22, 100,'...','EUC-JP');
+($str === FALSE) ? print "4 OK\n" : print "NG: $str\n";
$str = mb_strimwidth($euc_jp, 100, -10,'...','EUC-JP');
-($str === "") ? print "5 OK\n" : print "NG: $str\n";
+($str === FALSE) ? print "5 OK\n" : print "NG: $str\n";
$str = mb_strimwidth($euc_jp, -100, 10,'...','EUC-JP');
-($str !== "") ? print "6 OK: $str\n" : print "NG: $str\n";
+($str === FALSE) ? print "6 OK\n" : print "NG: $str\n";
?>
1: 0123¤³¤Îʸ»ú...
2: 0123¤³¤Îʸ»úÎó¤ÏÆüËܸì¤Ç¤¹¡£EUC-JP¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡£ÆüËܸì¤ÏÌÌÅݽ¤¤¡£
3: ¡£EUC-JP¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡£ÆüËܸì¤ÏÌÌÅݽ¤¤¡£
-4: EUC-JP¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡£ÆüËܸì¤ÏÌÌÅݽ¤¤¡£
+ERR: Warning
+4 OK
+ERR: Warning
5 OK
-6 OK: 0123¤³...
+ERR: Warning
+6 OK
// TODO: Add more tests
//$debug = true; // Uncomment this line to view error/warning/notice message in *.out file
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// SJIS string (BASE64 encoded)
$sjis = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==');
// TODO: Add more tests
//$debug = true; // Uncomment this line to view error/warning/notice message in *.out file
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// SJIS string (BASE64 encoded)
$sjis = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==');
// Using Encoding List Array
echo "== ARRAY ENCODING LIST ==\n";
-$a = array(0=>'UTF-8',1=>'EUC-JP', 2=>'SJIS', 3=>'JIS');
-
+$a = array(0=>'JIS', 1=>'UTF-8', 2=>'EUC-JP', 3=>'SJIS');
$s = $jis;
$s = mb_convert_encoding($s, 'EUC-JP', $a);
print("EUC-JP: $s\n"); // EUC-JP
// Using Detect Order
echo "== DETECT ORDER ==\n";
-mb_detect_order('auto');
-
-
$s = $jis;
-$s = mb_convert_encoding($s, 'EUC-JP');
+$s = mb_convert_encoding($s, 'EUC-JP', 'auto');
print("EUC-JP: $s\n"); // EUC-JP
$s = $euc_jp;
-$s = mb_convert_encoding($s, 'SJIS');
+$s = mb_convert_encoding($s, 'SJIS', 'auto');
print("SJIS: ".base64_encode($s)."\n"); // SJIS
$s = $euc_jp;
-$s = mb_convert_encoding($s, 'JIS');
+$s = mb_convert_encoding($s, 'JIS', 'auto');
print("JIS: ".base64_encode($s)."\n"); // JIS
// TODO: Add more tests
//$debug = true; // Uncomment this line to view error/warning/notice message in *.out file
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// SJIS string (BASE64 encoded)
$sjis = base64_decode('k/qWe4zqg2WDTINYg2eCxYK3gUIwMTIzNIJUglWCVoJXgliBQg==');
// TODO: Add more encoding, strings.....
//$debug = true;
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// EUC-JP
$euc_jp = '0123¤³¤Îʸ»úÎó¤ÏÆüËܸì¤Ç¤¹¡£EUC-JP¤ò»È¤Ã¤Æ¤¤¤Þ¤¹¡£ÆüËܸì¤ÏÌÌÅݽ¤¤¡£';
//$debug=true;
ini_set('include_path','.');
-include_once('common.inc');
+include_once('common.php');
// restore detect_order to 'auto'
mb_detect_order('auto');
--TEST--
-mb_strlen()
+strlen()
--SKIPIF--
<?php include('skipif.inc'); ?>
--POST--