Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / string_type_native.lib.php
blob4267a1923d2ad8bf04e0a548a40e0927dd6f82fc
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Specialized String Functions for phpMyAdmin
6 * Defines a set of function callbacks that have a pure C version available if
7 * the "ctype" extension is available, but otherwise have PHP versions to use
8 * (that are slower).
10 * The SQL Parser code relies heavily on these functions.
12 * @package PhpMyAdmin-String
13 * @subpackage Native
15 if (! defined('PHPMYADMIN')) {
16 exit;
19 /**
20 * Checks if a character is an alphanumeric one
22 * @param string $c character to check for
24 * @return boolean whether the character is an alphanumeric one or not
26 function PMA_STR_isAlnum($c)
28 return (PMA_STR_isUpper($c) || PMA_STR_isLower($c) || PMA_STR_isDigit($c));
29 } // end of the "PMA_STR_isAlnum()" function
31 /**
32 * Checks if a character is an alphabetic one
34 * @param string $c character to check for
36 * @return boolean whether the character is an alphabetic one or not
38 function PMA_STR_isAlpha($c)
40 return (PMA_STR_isUpper($c) || PMA_STR_isLower($c));
41 } // end of the "PMA_STR_isAlpha()" function
43 /**
44 * Checks if a character is a digit
46 * @param string $c character to check for
48 * @return boolean whether the character is a digit or not
50 function PMA_STR_isDigit($c)
52 $ord_zero = 48; //ord('0');
53 $ord_nine = 57; //ord('9');
54 $ord_c = ord($c);
56 return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
57 } // end of the "PMA_STR_isDigit()" function
59 /**
60 * Checks if a character is an upper alphabetic one
62 * @param string $c character to check for
64 * @return boolean whether the character is an upper alphabetic one or not
66 function PMA_STR_isUpper($c)
68 $ord_zero = 65; //ord('A');
69 $ord_nine = 90; //ord('Z');
70 $ord_c = ord($c);
72 return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
73 } // end of the "PMA_STR_isUpper()" function
75 /**
76 * Checks if a character is a lower alphabetic one
78 * @param string $c character to check for
80 * @return boolean whether the character is a lower alphabetic one or not
82 function PMA_STR_isLower($c)
84 $ord_zero = 97; //ord('a');
85 $ord_nine = 122; //ord('z');
86 $ord_c = ord($c);
88 return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
89 } // end of the "PMA_STR_isLower()" function
91 /**
92 * Checks if a character is a space one
94 * @param string $c character to check for
96 * @return boolean whether the character is a space one or not
98 function PMA_STR_isSpace($c)
100 $ord_space = 32; //ord(' ')
101 $ord_tab = 9; //ord('\t')
102 $ord_CR = 13; //ord('\n')
103 $ord_NOBR = 160; //ord('U+00A0);
104 $ord_c = ord($c);
106 return ($ord_c == $ord_space
107 || $ord_c == $ord_NOBR
108 || PMA_STR_numberInRangeInclusive($ord_c, $ord_tab, $ord_CR));
109 } // end of the "PMA_STR_isSpace()" function
112 * Checks if a character is an hexadecimal digit
114 * @param string $c character to check for
116 * @return boolean whether the character is an hexadecimal digit or not
118 function PMA_STR_isHexDigit($c)
120 $ord_Aupper = 65; //ord('A');
121 $ord_Fupper = 70; //ord('F');
122 $ord_Alower = 97; //ord('a');
123 $ord_Flower = 102; //ord('f');
124 $ord_zero = 48; //ord('0');
125 $ord_nine = 57; //ord('9');
126 $ord_c = ord($c);
128 return (PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine)
129 || PMA_STR_numberInRangeInclusive($ord_c, $ord_Aupper, $ord_Fupper)
130 || PMA_STR_numberInRangeInclusive($ord_c, $ord_Alower, $ord_Flower));
131 } // end of the "PMA_STR_isHexDigit()" function