File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / mbstring / tests / mb_strtolower_variation3.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:47:57 2012 UTC (12 years, 5 months ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

--TEST--
Test mb_strtolower() function : usage variations - pass mixed ASCII and non-ASCII strings
--SKIPIF--
<?php
extension_loaded('mbstring') or die('skip');
function_exists('mb_strtolower') or die("skip mb_strtolower() is not available in this build");
?>
--FILE--
<?php
/* Prototype  : string mb_strtolower(string $sourcestring [, string $encoding])
 * Description: Returns a lowercased version of $sourcestring
 * Source code: ext/mbstring/mbstring.c
 */

/*
 * Pass a Japanese string and a mixed Japanese and ASCII string to mb_strtolower
 * to check correct conversion is occuring (Japanese characters should not be converted).
 */

echo "*** Testing mb_strtolower() : usage variations ***\n";

$string_mixed = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCUEhQLiAwMTIzNO+8le+8lu+8l++8mO+8meOAgg==');
$string_mixed_lower = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCcGhwLiAwMTIzNO+8le+8lu+8l++8mO+8meOAgg==');
$string_all_mb = base64_decode('5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CC');

echo "\n-- Mixed string (mulitbyte and ASCII characters) --\n";
$a = mb_strtolower($string_mixed, 'UTF-8');
var_dump(base64_encode($a));
if ($a == $string_mixed_lower) {
	echo "Correctly Converted\n";
} else {
	echo "Incorrectly Converted\n";
}

echo "\n-- Multibyte Only String--\n";
$b = mb_strtolower($string_all_mb, 'UTF-8');
var_dump(base64_encode($b));
if ($b == $string_all_mb) { // Japanese characters only - should not be any conversion
	echo "Correctly Converted\n";
} else {
	echo "Incorrectly Converted\n";
}

echo "Done";
?>

--EXPECTF--
*** Testing mb_strtolower() : usage variations ***

-- Mixed string (mulitbyte and ASCII characters) --
string(80) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CCcGhwLiAwMTIzNO+8le+8lu+8l++8mO+8meOAgg=="
Correctly Converted

-- Multibyte Only String--
string(40) "5pel5pys6Kqe44OG44Kt44K544OI44Gn44GZ44CC"
Correctly Converted
Done

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>