2 /* vim: set expandtab sw=4 ts=4 sts=4: */
4 * Implements PMA_StringByte interface using native PHP functions.
6 * @package PhpMyAdmin-String
9 if (! defined('PHPMYADMIN')) {
13 require_once 'libraries/StringAbstractType.class.php';
16 * Implements PMA_StringByte interface using native PHP functions.
18 * @package PhpMyAdmin-String
20 * @todo May be join this class with PMA_StringNative class
22 class PMA_StringNativeType
extends PMA_StringAbstractType
25 * Checks if a character is an alphanumeric one
27 * @param string $c character to check for
29 * @return boolean whether the character is an alphanumeric one or not
31 public function isAlnum($c)
33 return ($this->isAlpha($c) ||
$this->isDigit($c));
34 } // end of the "isAlnum()" function
37 * Checks if a character is an alphabetic one
39 * @param string $c character to check for
41 * @return boolean whether the character is an alphabetic one or not
43 public function isAlpha($c)
45 return ($this->isUpper($c) ||
$this->isLower($c));
46 } // end of the "isAlpha()" function
49 * Checks if a character is a digit
51 * @param string $c character to check for
53 * @return boolean whether the character is a digit or not
55 public function isDigit($c)
57 $ord_zero = 48; //ord('0');
58 $ord_nine = 57; //ord('9');
61 return $this->numberInRangeInclusive($ord_c, $ord_zero, $ord_nine);
62 } // end of the "isDigit()" function
65 * Checks if a character is an upper alphabetic one
67 * @param string $c character to check for
69 * @return boolean whether the character is an upper alphabetic one or not
71 public function isUpper($c)
73 $ord_A = 65; //ord('A');
74 $ord_Z = 90; //ord('Z');
77 return $this->numberInRangeInclusive($ord_c, $ord_A, $ord_Z);
78 } // end of the "isUpper()" function
81 * Checks if a character is a lower alphabetic one
83 * @param string $c character to check for
85 * @return boolean whether the character is a lower alphabetic one or not
87 public function isLower($c)
89 $ord_a = 97; //ord('a');
90 $ord_z = 122; //ord('z');
93 return $this->numberInRangeInclusive($ord_c, $ord_a, $ord_z);
94 } // end of the "isLower()" function
97 * Checks if a character is a space one
99 * @param string $c character to check for
101 * @return boolean whether the character is a space one or not
103 public function isSpace($c)
105 $ord_space = 32; //ord(' ')
106 $ord_tab = 9; //ord('\t')
107 $ord_CR = 13; //ord('\n')
108 $ord_NOBR = 160; //ord('U+00A0);
111 return ($ord_c == $ord_space
112 ||
$ord_c == $ord_NOBR
113 ||
$this->numberInRangeInclusive($ord_c, $ord_tab, $ord_CR));
114 } // end of the "isSpace()" function
117 * Checks if a character is an hexadecimal digit
119 * @param string $c character to check for
121 * @return boolean whether the character is an hexadecimal digit or not
123 public function isHexDigit($c)
125 $ord_Aupper = 65; //ord('A');
126 $ord_Fupper = 70; //ord('F');
127 $ord_Alower = 97; //ord('a');
128 $ord_Flower = 102; //ord('f');
129 $ord_zero = 48; //ord('0');
130 $ord_nine = 57; //ord('9');
133 return ($this->numberInRangeInclusive($ord_c, $ord_zero, $ord_nine)
134 ||
$this->numberInRangeInclusive($ord_c, $ord_Aupper, $ord_Fupper)
135 ||
$this->numberInRangeInclusive($ord_c, $ord_Alower, $ord_Flower));
136 } // end of the "isHexDigit()" function