1. Check existence of mb_string, mysql and xml extensions before installation.
[openemr.git] / phpmyadmin / libraries / stringMb.lib.php
blob7be406c9a48da04b8ae1f01c53be98c6c98de041
1 <?php
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.
10 * @package PhpMyAdmin
12 if (! defined('PHPMYADMIN')) {
13 exit;
16 if (!@function_exists('mb_ord')) {
17 /**
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)
30 $matches = array();
31 $bFind = preg_match(
32 $pattern, mb_substr($subject, $offset), $matches, PREG_OFFSET_CAPTURE
34 if (1 !== $bFind) {
35 return false;
38 return $matches[1][1] + $offset;
41 /**
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) {
51 return 0;
54 $str = mb_convert_encoding($string, "UCS-4BE", "UTF-8");
55 $substr = mb_substr($str, 0, 1, "UCS-4BE");
56 $val = unpack("N", $substr);
57 return $val[1];
60 /**
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(
70 pack("N", $ascii),
71 mb_internal_encoding(),
72 'UCS-4BE'