Translation update done using Pootle.
[phpmyadmin/ammaryasirr.git] / libraries / string_type_native.lib.php
blob46a65440bd4631c10669fbbceb22dc41f25f8fc7
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 * @package phpMyAdmin-StringType-Native
18 /**
19 * Checks if a character is an alphanumeric one
21 * @param string character to check for
22 * @return boolean whether the character is an alphanumeric one or not
24 function PMA_STR_isAlnum($c)
26 return (PMA_STR_isUpper($c) || PMA_STR_isLower($c) || PMA_STR_isDigit($c));
27 } // end of the "PMA_STR_isAlnum()" function
29 /**
30 * Checks if a character is an alphabetic one
32 * @param string character to check for
33 * @return boolean whether the character is an alphabetic one or not
35 function PMA_STR_isAlpha($c)
37 return (PMA_STR_isUpper($c) || PMA_STR_isLower($c));
38 } // end of the "PMA_STR_isAlpha()" function
40 /**
41 * Checks if a character is a digit
43 * @param string character to check for
44 * @return boolean whether the character is a digit or not
46 function PMA_STR_isDigit($c)
48 $ord_zero = 48; //ord('0');
49 $ord_nine = 57; //ord('9');
50 $ord_c = ord($c);
52 return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
53 } // end of the "PMA_STR_isDigit()" function
55 /**
56 * Checks if a character is an upper alphabetic one
58 * @param string character to check for
59 * @return boolean whether the character is an upper alphabetic one or not
61 function PMA_STR_isUpper($c)
63 $ord_zero = 65; //ord('A');
64 $ord_nine = 90; //ord('Z');
65 $ord_c = ord($c);
67 return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
68 } // end of the "PMA_STR_isUpper()" function
70 /**
71 * Checks if a character is a lower alphabetic one
73 * @param string character to check for
74 * @return boolean whether the character is a lower alphabetic one or not
76 function PMA_STR_isLower($c)
78 $ord_zero = 97; //ord('a');
79 $ord_nine = 122; //ord('z');
80 $ord_c = ord($c);
82 return PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
83 } // end of the "PMA_STR_isLower()" function
85 /**
86 * Checks if a character is a space one
88 * @param string character to check for
89 * @return boolean whether the character is a space one or not
91 function PMA_STR_isSpace($c)
93 $ord_space = 32; //ord(' ')
94 $ord_tab = 9; //ord('\t')
95 $ord_CR = 13; //ord('\n')
96 $ord_NOBR = 160; //ord('U+00A0);
97 $ord_c = ord($c);
99 return ($ord_c == $ord_space
100 || $ord_c == $ord_NOBR
101 || PMA_STR_numberInRangeInclusive($ord_c, $ord_tab, $ord_CR));
102 } // end of the "PMA_STR_isSpace()" function
105 * Checks if a character is an hexadecimal digit
107 * @param string character to check for
108 * @return boolean whether the character is an hexadecimal digit or not
110 function PMA_STR_isHexDigit($c)
112 $ord_Aupper = 65; //ord('A');
113 $ord_Fupper = 70; //ord('F');
114 $ord_Alower = 97; //ord('a');
115 $ord_Flower = 102; //ord('f');
116 $ord_zero = 48; //ord('0');
117 $ord_nine = 57; //ord('9');
118 $ord_c = ord($c);
120 return (PMA_STR_numberInRangeInclusive($ord_c, $ord_zero, $ord_nine)
121 || PMA_STR_numberInRangeInclusive($ord_c, $ord_Aupper, $ord_Fupper)
122 || PMA_STR_numberInRangeInclusive($ord_c, $ord_Alower, $ord_Flower));
123 } // end of the "PMA_STR_isHexDigit()" function