TeamSpeak 3 PHP Framework
1.1.12
|
Helper class for char handling. More...
Public Member Functions | |
__construct ($char) | |
The TeamSpeak3_Helper_Char constructor. | |
isLetter () | |
Returns true if the character is a letter. | |
isDigit () | |
Returns true if the character is a decimal digit. | |
isSpace () | |
Returns true if the character is a space. | |
isMark () | |
Returns true if the character is a mark. | |
isControl () | |
Returns true if the character is a control character (i.e. | |
isPrintable () | |
Returns true if the character is a printable character. | |
isNull () | |
Returns true if the character is the Unicode character 0x0000 ("\0"). | |
isUpper () | |
Returns true if the character is an uppercase letter. | |
isLower () | |
Returns true if the character is a lowercase letter. | |
toUpper () | |
Returns the uppercase equivalent if the character is lowercase. | |
toLower () | |
Returns the lowercase equivalent if the character is uppercase. | |
toAscii () | |
Returns the ascii value of the character. | |
toUnicode () | |
Returns the Unicode value of the character. | |
toHex () | |
Returns the hexadecimal value of the char. | |
toString () | |
Returns the character as a standard string. | |
toInt () | |
Returns the integer value of the character. | |
__toString () | |
Returns the character as a standard string. | |
Static Public Member Functions | |
static | fromHex ($hex) |
Returns the TeamSpeak3_Helper_Char based on a given hex value. | |
Protected Attributes | |
$char = null |
TeamSpeak3_Helper_Char::__construct | ( | $ | char | ) |
The TeamSpeak3_Helper_Char constructor.
string | $var |
TeamSpeak3_Helper_Exception |
Definition at line 48 of file Char.php.
{ if(strlen($char) != 1) { throw new TeamSpeak3_Helper_Exception("char parameter may not contain more or less than one character"); } $this->char = strval($char); }
Returns the uppercase equivalent if the character is lowercase.
Definition at line 153 of file Char.php.
References isUpper().
{ return ($this->isUpper()) ? $this : new self(strtoupper($this)); }
Returns the lowercase equivalent if the character is uppercase.
Definition at line 163 of file Char.php.
References isLower().
{ return ($this->isLower()) ? $this : new self(strtolower($this)); }
Returns the Unicode value of the character.
Definition at line 183 of file Char.php.
{ $h = ord($this->char{0}); if($h <= 0x7F) { return $h; } else if($h < 0xC2) { return FALSE; } else if($h <= 0xDF) { return ($h & 0x1F) << 6 | (ord($this->char{1}) & 0x3F); } else if($h <= 0xEF) { return ($h & 0x0F) << 12 | (ord($this->char{1}) & 0x3F) << 6 | (ord($this->char{2}) & 0x3F); } else if($h <= 0xF4) { return ($h & 0x0F) << 18 | (ord($this->char{1}) & 0x3F) << 12 | (ord($this->char{2}) & 0x3F) << 6 | (ord($this->char{3}) & 0x3F); } else { return FALSE; } }
static TeamSpeak3_Helper_Char::fromHex | ( | $ | hex | ) | [static] |
Returns the TeamSpeak3_Helper_Char based on a given hex value.
string | $hex |
TeamSpeak3_Helper_Exception |
Definition at line 230 of file Char.php.
{ if(strlen($hex) != 2) { throw new TeamSpeak3_Helper_Exception("given parameter '" . $hex . "' is not a valid hexadecimal number"); } return new self(chr(hexdec($hex))); }