2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /** String Functions for phpMyAdmin
5 * If mb_* functions don't exist, we create the ones we need and they'll use the
6 * standard string functions.
8 * All mb_* functions created by pMA should behave as mb_* functions.
12 if (! defined('PHPMYADMIN')) {
16 if (!@function_exists
('mb_ord')) {
17 mb_internal_encoding('utf-8');
20 * Perform a regular expression match
22 * Take care: might not work with lookbehind expressions.
24 * @param string $pattern Pattern to search for
25 * @param string $subject Input string
26 * @param int $offset Start from search
28 * @return int 1 if matched, 0 if doesn't, false on failure
30 function mb_preg_strpos($pattern, $subject, $offset = 0)
34 $pattern, mb_substr($subject, $offset), $matches, PREG_OFFSET_CAPTURE
40 return $matches[1][1] +
$offset;
44 * Get the ordinal value of a string
46 * @param string $string the string for which ord is required
48 * @return int the ord value
50 function mb_ord($string)
52 if (false === $string ||
null === $string ||
'' === $string) {
56 $str = mb_convert_encoding($string, "UCS-4BE", "UTF-8");
57 $substr = mb_substr($str, 0, 1, "UCS-4BE");
58 $val = unpack("N", $substr);
63 * Get the character of an ASCII
65 * @param int $ascii the ASCII code for which character is required
67 * @return string the character
69 function mb_chr($ascii)
71 return mb_convert_encoding(
73 mb_internal_encoding(),