This implements an mb_str_pad fallback function, but there is no mb_str_pad in PHP documentation, and the doc comments are really weird -- it says it returns an integer!
If this function is created from whole cloth and doesn't exist in PHP, it should be given a MediaWiki style name and not be done with a function_exists check as though it were a compat function.
had stict standards issues with setFakeSlaveLag() and setFakeMaster().
* (bug 451) Improve the phrase mappings of the Chinese converter arrays.
* (bug 12487) Rights log is not fully internationalized
-* (bug 8604) padright: and similar functions fail with non-ASCII arguments
=== API changes in 1.13 ===
}
}
-if ( !function_exists( 'mb_str_pad' ) ) {
- /**
- * Fallback implementation of mb_str_pad, hardcoded to UTF-8.
- * @param $input String: input string
- * @param $pad_length Integer: how much to pad
- * @param $pad_string Character used for padding, only one!
- * @param $pad_type Only STR_PAD_LEFT and STR_PAD_RIGHT supported.
- * @return int
- */
- function mb_str_pad( $input, $pad_length, $pad_string, $pad_type ) {
- $toPad = $pad_length - mb_strlen( $input );
- if ( $toPad <= 0 ) return $input;
- for ( $i = 0; $i < $toPad; $i++ ) {
- if ( $pad_type === STR_PAD_LEFT ) {
- $input = $pad_string . $input;
- } elseif( $pad_type === STR_PAD_RIGHT ) {
- $input .= $pad_string;
- }
- }
- return $input;
- }
-}
-
if ( !function_exists( 'array_diff_key' ) ) {
/**
* Exists in PHP 5.1.0+
static function pad( $string = '', $length = 0, $char = 0, $direction = STR_PAD_RIGHT ) {
$length = min( max( $length, 0 ), 500 );
- $char = mb_substr( $char, 0, 1 );
- return ( $string !== '' && (int)$length > 0 && mb_strlen( trim($char) ) > 0 )
- ? mb_str_pad( $string, $length, $char, $direction )
+ $char = substr( $char, 0, 1 );
+ return ( $string !== '' && (int)$length > 0 && strlen( trim( (string)$char ) ) > 0 )
+ ? str_pad( $string, $length, (string)$char, $direction )
: $string;
}