typo
[phpmyadmin/arisferyanto.git] / libraries / string_type_native.lib.php
blob337c23df7f8a051cfc5f9f3cfa560c8a0ed72927
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Specialized String Functions for phpMyAdmin
6 * Copyright 2002 Robin Johnson <robbat2@users.sourceforge.net>
7 * http://www.orbis-terrarum.net/?l=people.robbat2
9 * Defines a set of function callbacks that have a pure C version available if
10 * the "ctype" extension is available, but otherwise have PHP versions to use
11 * (that are slower).
13 * The SQL Parser code relies heavily on these functions.
15 * @version $Id$
16 * @package phpMyAdmin-StringType-Native
19 /**
20 * Checks if a character is an alphanumeric one
22 * @uses PMA_STR_isUpper()
23 * @uses PMA_STR_isLower()
24 * @uses PMA_STR_isDigit()
25 * @param string character to check for
26 * @return boolean whether the character is an alphanumeric one or not
28 function PMA_STR_isAlnum($c)
30 return (PMA_STR_isUpper($c) || PMA_STR_isLower($c) || PMA_STR_isDigit($c));
31 } // end of the "PMA_STR_isAlnum()" function
33 /**
34 * Checks if a character is an alphabetic one
36 * @uses PMA_STR_isUpper()
37 * @uses PMA_STR_isLower()
38 * @param string character to check for
39 * @return boolean whether the character is an alphabetic one or not
41 function PMA_STR_isAlpha($c)
43 return (PMA_STR_isUpper($c) || PMA_STR_isLower($c));
44 } // end of the "PMA_STR_isAlpha()" function
46 /**
47 * Checks if a character is a digit
49 * @uses PMA_STR_numberInRangeInclusive()
50 * @uses ord()
51 * @param string character to check for
52 * @return boolean whether the character is a digit or not
54 function PMA_STR_isDigit($c)
56 $ord_zero = 48; //ord('0');
57 $ord_nine = 57; //ord('9');
58 $ord_c = ord($c);
60 return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
61 } // end of the "PMA_STR_isDigit()" function
63 /**
64 * Checks if a character is an upper alphabetic one
66 * @uses PMA_STR_numberInRangeInclusive()
67 * @uses ord()
68 * @param string character to check for
69 * @return boolean whether the character is an upper alphabetic one or not
71 function PMA_STR_isUpper($c)
73 $ord_zero = 65; //ord('A');
74 $ord_nine = 90; //ord('Z');
75 $ord_c = ord($c);
77 return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
78 } // end of the "PMA_STR_isUpper()" function
80 /**
81 * Checks if a character is a lower alphabetic one
83 * @uses PMA_STR_numberInRangeInclusive()
84 * @uses ord()
85 * @param string character to check for
86 * @return boolean whether the character is a lower alphabetic one or not
88 function PMA_STR_isLower($c)
90 $ord_zero = 97; //ord('a');
91 $ord_nine = 122; //ord('z');
92 $ord_c = ord($c);
94 return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
95 } // end of the "PMA_STR_isLower()" function
97 /**
98 * Checks if a character is a space one
100 * @uses PMA_STR_numberInRangeInclusive()
101 * @uses ord()
102 * @param string character to check for
103 * @return boolean whether the character is a space one or not
105 function PMA_STR_isSpace($c)
107 $ord_space = 32; //ord(' ')
108 $ord_tab = 9; //ord('\t')
109 $ord_CR = 13; //ord('\n')
110 $ord_NOBR = 160; //ord('U+00A0);
111 $ord_c = ord($c);
113 return ($ord_c == $ord_space
114 || $ord_c == $ord_NOBR
115 || PMA_STR_numberInRangeInclusive($ord_c, $ord_tab, $ord_CR));
116 } // end of the "PMA_STR_isSpace()" function
119 * Checks if a character is an hexadecimal digit
121 * @uses PMA_STR_numberInRangeInclusive()
122 * @uses ord()
123 * @param string character to check for
124 * @return boolean whether the character is an hexadecimal digit or not
126 function PMA_STR_isHexDigit($c)
128 $ord_Aupper = 65; //ord('A');
129 $ord_Fupper = 70; //ord('F');
130 $ord_Alower = 97; //ord('a');
131 $ord_Flower = 102; //ord('f');
132 $ord_zero = 48; //ord('0');
133 $ord_nine = 57; //ord('9');
134 $ord_c = ord($c);
136 return (PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine)
137 || PMA_STR_numberInRangeInclusive($ord_c, $ord_Aupper, $ord_Fupper)
138 || PMA_STR_numberInRangeInclusive($ord_c, $ord_Alower, $ord_Flower));
139 } // end of the "PMA_STR_isHexDigit()" function