app/Functions/FunctionsRtl.php
public static function getChar(string $text, int $offset): array
    {
        if ($text == '') {
            return [
                'letter' => '',
                'length' => 0,
            ];
        }

        $char   = substr($text, $offset, 1);
        $length = 1;
        if ((ord($char) & 0xE0) == 0xC0) {
            $length = 2;
        }
        if ((ord($char) & 0xF0) == 0xE0) {
            $length = 3;
        }
        if ((ord($char) & 0xF8) == 0xF0) {
            $length = 4;
        }
        $letter = substr($text, $offset, $length);

        return [
            'letter' => $letter,
            'length' => $length,
        ];
    }
public static function getChar(string $text, int $offset): array
    {
        if ($text == '') {
            return [
                'letter' => '',
                'length' => 0,
            ];
        }

        $char   = substr($text, $offset, 1);
        $length = 1;
        if ((ord($char) & 0xE0) == 0xC0) {
            $length = 2;
        }
        if ((ord($char) & 0xF0) == 0xE0) {
            $length = 3;
        }
        if ((ord($char) & 0xF8) == 0xF0) {
            $length = 4;
        }
        $letter = substr($text, $offset, $length);

        return [
            'letter' => $letter,
            'length' => $length,
        ];
    }
public static function getChar ( string $ text , int $ offset ) : array { if ( $ text == '' ) { return [ 'letter' => '' , 'length' => 0 , ] ; } $ char = substr ( $ text , $ offset , 1 ) ; $ length = 1 ; if ( ( ord ( $ char ) & 0xE0 ) == 0xC0 ) { $ length = 2 ; } if ( ( ord ( $ char ) & 0xF0 ) == 0xE0 ) { $ length = 3 ; } if ( ( ord ( $ char ) & 0xF8 ) == 0xF0 ) { $ length = 4 ; } $ letter = substr ( $ text , $ offset , $ length ) ; return [ 'letter' => $ letter , 'length' => $ length , ] ; }
Get the next character from an input string

@param string $text
@param int    $offset

@return array
Get the next character from an input string