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')) {
18 * Perform a regular expression match
20 * Take care: might not work with lookbehind expressions.
22 * @param string $pattern Pattern to search for
23 * @param string $subject Input string
24 * @param int $offset Start from search
26 * @return int 1 if matched, 0 if doesn't, false on failure
28 function mb_preg_strpos($pattern, $subject, $offset = 0)
32 $pattern, mb_substr($subject, $offset), $matches, PREG_OFFSET_CAPTURE
38 return $matches[1][1] +
$offset;
42 * Get the ordinal value of a string
44 * @param string $string the string for which ord is required
46 * @return int the ord value
48 function mb_ord($string)
50 if (false === $string ||
null === $string ||
'' === $string) {
54 $str = mb_convert_encoding($string, "UCS-4BE", "UTF-8");
55 $substr = mb_substr($str, 0, 1, "UCS-4BE");
56 $val = unpack("N", $substr);
61 * Get the character of an ASCII
63 * @param int $ascii the ASCII code for which character is required
65 * @return string the character
67 function mb_chr($ascii)
69 return mb_convert_encoding(
71 mb_internal_encoding(),