static function RTLMaker::get_char_type in PersianTools 8
Detects and returns a character's type.
2 calls to RTLMaker::get_char_type()
- RTLMaker::convert_sm in src/
RTLMaker.php - Main function for multiple features and fixes of persiantools module.
- RTLMaker::fix_mixed_path in src/
RTLMaker.php - Fix mixed-up paths in rtl blocks. Logic: Gets triggered once a starting '.' or '/' is detected after a whitespace. The correcting symbol is inserted once an english char is seen inside the path.
File
- src/
RTLMaker.php, line 253 - Contains \Drupal\persiantools\RTLMaker.
Class
Namespace
Drupal\persiantoolsCode
static function get_char_type($ch) {
if ($ch >= 'آ' && $ch <= 'ي' || $ch == 'ی') {
$type = RTLMaker::FA;
}
elseif ($ch >= 'a' && $ch <= 'z' || $ch >= 'A' && $ch <= 'Z') {
$type = RTLMaker::EN;
}
elseif (in_array($ch, RTLMaker::$OPENING_SYMS)) {
$type = RTLMaker::OPENING;
}
elseif ($ch >= '0' && $ch <= '9') {
$type = RTLMaker::DIGIT;
}
elseif (in_array($ch, RTLMaker::$STATMENT_END)) {
$type = RTLMaker::EOS;
}
elseif ($ch == '/') {
$type = RTLMaker::SLASH;
}
elseif ($ch == ' ' || $ch == '\\n') {
$type = RTLMaker::WS;
}
else {
// Type not detected.
$type = RTLMaker::UN;
}
return $type;
}