Looks back at the previous character in the string

@param array $charArray The char array
@param int $currPosition The current position
@return string|null The previous character if there is one, otherwise null
174111
private function lookBehind(array $charArray, int $currPosition)
    {
        if ($currPosition === 0 || count($charArray) === 0) {
            return null;
        }

        return $charArray[$currPosition - 1];
    }
218637
public function getSubstr($str, $charset, $start, $length = null)
    {
        $mb = $this->getMbCharset($charset);
        if ($mb !== false) {
            return mb_substr($str, $start, $length, $mb);
        }
        $ic = $this->getIconvAlias($charset);
        if ($length === null) {
            $length = iconv_strlen($str, $ic);
        }
        return iconv_substr($str, $start, $length, $ic);
    }
559835
public function setCharset($charset)
    {
        $prev = $this->charset;

        $charset = strtoupper($charset);
        $charset = null === $charset || 'UTF-8' === $charset || 'UTF8' === $charset ? 'CP1252' : $charset;

        $this->charset = $charset;

        return $prev;
    }
1176232
function _processCoordinate($last_attr, $cur_attr, $char)
    {
        $output = '';

        if ($last_attr != $cur_attr) {
            $close = $open = '';
            if ($last_attr->foreground != $cur_attr->foreground) {
                if ($cur_attr->foreground != 'white') {
                    $open.= '<span style="color: ' . $cur_attr->foreground . '">';
                }
                if ($last_attr->foreground != 'white') {
                    $close = '</span>' . $close;
                }
            }
            if ($last_attr->background != $cur_attr->background) {
                if ($cur_attr->background != 'black') {
                    $open.= '<span style="background: ' . $cur_attr->background . '">';
                }
                if ($last_attr->background != 'black') {
                    $close = '</span>' . $close;
                }
            }
            if ($last_attr->bold != $cur_attr->bold) {
                if ($cur_attr->bold) {
                    $open.= '<b>';
                } else {
                    $close = '</b>' . $close;
                }
            }
            if ($last_attr->underline != $cur_attr->underline) {
                if ($cur_attr->underline) {
                    $open.= '<u>';
                } else {
                    $close = '</u>' . $close;
                }
            }
            if ($last_attr->blink != $cur_attr->blink) {
                if ($cur_attr->blink) {
                    $open.= '<blink>';
                } else {
                    $close = '</blink>' . $close;
                }
            }
            $output.= $close . $open;
        }

        $output.= htmlspecialchars($char);

        return $output;
    }
480683
private byte lastL_R_AL() {
        for (int i = prologue.length(); i > 0; ) {
            int uchar = prologue.codePointBefore(i);
            i -= Character.charCount(uchar);
            byte dirProp = (byte)getCustomizedClass(uchar);
            if (dirProp == L) {
                return _L;
            }
            if (dirProp == R || dirProp == AL) {
                return _R;
            }
            if(dirProp == B) {
                return _ON;
            }
        }
        return _ON;
    }
916833
public static function compare($charA, $charB): int
    {
        self::handleIncomingChar($charA, $charB);

        return (string) $charA <=> (string) $charB;
    }
847845
protected function characterReference() {
        $ref = $this->decodeCharacterReference();
        if ($ref !== false) {
            $this->buffer($ref);
            return true;
        }
        return false;
    }
1191937
static public function unflatten(array $array, $segmentationCharacter = self::SEGMENTATION_CHARACTER) {
		ksort($array);
		$unflatArray = array();
		foreach ($array as $key => $value) {
			self::insertValueIntoStructureByPath(explode($segmentationCharacter, $key), $unflatArray, $value);
		}
		return $unflatArray;
	}
857610
public static void sort(char[] charArray) {
        boolean swapped = true;
        
        while(swapped) {
            swapped = false;
            
            for(int i = 0; i < (charArray.length - 1 ); i++) {
                if(charArray[i] > charArray[i + 1]) {
                    TrivialSwap.swap(charArray, i, i + 1);
                    
                    swapped = true;
                }
            }            
        }
    }
388842
public function peekChars($chars)
    {
        return in_array($this->peek(), is_array($chars) ? $chars : str_split($chars), true);
    }
194718
public function fixPrevNext(&$arr) {
        $tweaked = false;

        $prev = null;
        foreach ($arr as $key=>$el) {
            $prev_value = $arr[$key]->previous;
            $next_value = $arr[$key]->next;

            $arr[$key]->next     = null;
            $arr[$key]->previous = null;
            if ($prev !== null) {
                $arr[$prev]->next    = $arr[$key]->name;
                $arr[$key]->previous = $arr[$prev]->name;
            }
            $prev = $key;

            if ($prev_value != $arr[$key]->previous or $next_value != $arr[$key]->next) {
                $tweaked = true;
            }
        }

        return $tweaked;
    }
135227
public function offsetAfter ($offset) {
		return ($offset < $this->_length) ? static::Substring($this->_string, $offset) : static::EMPTY_CHAR;
	}
694993
protected function uniOrd($char)
    {
        $h = ord($char[0]);

        if ($h <= 0x7f) {
            return $h;
        } elseif ($h < 0xc2) {
            return null;
        } elseif ($h <= 0xdf) {
            return ($h & 0x1f) << 6 | (ord($char[1]) & 0x3f);
        } elseif ($h <= 0xef) {
            return ($h & 0x0f) << 12 | (ord($char[1]) & 0x3f) << 6
                                     | (ord($char[2]) & 0x3f);
        } elseif ($h <= 0xf4) {
            return ($h & 0x0f) << 18 | (ord($char[1]) & 0x3f) << 12
                                     | (ord($char[2]) & 0x3f) << 6
                                     | (ord($char[3]) & 0x3f);
        } else {
            return null;
        }
    }
301355
function CharConvert(&$array, $encoding) {

		// identical encoding - end here
		if ($encoding == $this->encoding) {
			return;
		}

		// loop thru array
		foreach ($array as $key => $value) {

			// go recursive
			if (is_array($value)) {
				$this->CharConvert($array[$key], $encoding);
			}

			// convert string
			elseif (is_string($value)) {
				$array[$key] = trim(getid3_lib::iconv_fallback($encoding, $this->encoding, $value));
			}
		}
	}
521628
function _moveToPrevChar(&$contentctr, &$charctr, $content)
	{
		$lastchar = false;
		$charctr--;
		while ($charctr < 0) { // go back to previous $content[]
			$contentctr--;
			if ($contentctr < 0) {
				return false;
			}
			if ($this->usingCoreFont) {
				$charctr = strlen($content[$contentctr]) - 1;
			} else {
				$charctr = mb_strlen($content[$contentctr], $this->mb_enc) - 1;
			}
		}
		if ($this->usingCoreFont) {
			$lastchar = $content[$contentctr][$charctr];
		} else {
			$lastchar = mb_substr($content[$contentctr], $charctr, 1, $this->mb_enc);
		}
		return $lastchar;
	}
213197
function preProcess( $oldArray, $newArray )
    {
        $substr = $this->substringMatrix( $oldArray, $newArray );

        $nOldWords = count( $oldArray );
        $nNewWords = count( $newArray );

        /*
        $tmp = $substr['lengthMatrix'];
        print( "<pre>" );
        $this->dumpMatrix( $tmp, $nOldWords, $nNewWords );
        print( "</pre>" );
        */

        $strings = $this->substrings( $substr, $oldArray, $newArray );

        //Merge detected paragraphs
        $mergedStrings = array();
        foreach ( $strings as $sstring )
        {
            $mergedStrings = $mergedStrings + $sstring;
        }
        unset( $strings );

        //Check for changes in lead & inner paragraphs
        $offset = 0;
        $delOffset = 0;
        $internalOffset = 0;
        $merged = array();

        $oldOffset = -1;

        foreach ( $mergedStrings as $key => $wordArray )
        {
            if ( $oldOffset >= $wordArray['oldOffset'] )
            {
                continue;
            }

            $oldOffset = $wordArray['oldOffset'];

            //Check for inserted paragraphs
            $nk = $internalOffset;
            while ( $key > $offset )
            {
                $merged[$nk] = array( $offset => 'added' );
                $nk++;
                $offset++;
            }

            //Check for removed paragraphs
            $k = $internalOffset;
            while ( $oldOffset > $delOffset )
            {
                if ( $k < $nk )
                {
                    // Paragraph is changed
                    if ( array_key_exists( $delOffset, $merged[$k] ) )
                    {
                        // Old & new paragraph places is the same
                        $merged[$k][$delOffset] = 'changed';
                    }
                    else
                    {
                        $merged[$k][$delOffset] = 'removed';
                    }
                }
                else
                {
                    $merged[$k] = array( $delOffset => 'removed' );
                }
                $k++;
                $delOffset++;
            }

            $internalOffset = ($k > $nk) ? $k:$nk;

            //The default state - unchanged paragraph
            $merged[$internalOffset] = array( $key => 'unchanged' );
            $internalOffset++;
            $delOffset++;
            $offset++;
        }

        //Check for appended paragraphs
        $nk = $internalOffset;
        while ( $nNewWords > $offset )
        {
            $merged[$nk] = array( $offset => 'added' );
            $nk++;
            $offset++;
        }

        //Check for end-deleted paragraphs
        $k = $internalOffset;
        while ( $nOldWords > $delOffset )
        {
            if ( $k < $nk )
            {
                if ( array_key_exists( $delOffset, $merged[$k] ) )
                {
                    $merged[$k][$delOffset] = 'changed';
                }
                else
                {
                    $merged[$k][$delOffset] = 'removed';
                }
            }
            else
            {
                $merged[$k] = array( $delOffset => 'removed' );
            }
            $k++;
            $delOffset++;
        }

        return $merged;
    }
847448
public function getCharPositions($string, $startOffset, &$currentMap, &$ignoredChars)
    {
        if (!isset($currentMap['i']) || !isset($currentMap['p'])) {
            $currentMap['p'] = $currentMap['i'] = [];
        }

        $strlen = strlen($string);
        $charPos = count($currentMap['p']);
        $foundChars = 0;
        $invalid = false;
        for ($i = 0; $i < $strlen; ++$i) {
            $char = $string[$i];
            $size = self::$s_length_map[$char];
            if (0 == $size) {
                /* char is invalid, we must wait for a resync */
                $invalid = true;
                continue;
            } else {
                if (true === $invalid) {
                    /* We mark the chars as invalid and start a new char */
                    $currentMap['p'][$charPos + $foundChars] = $startOffset + $i;
                    $currentMap['i'][$charPos + $foundChars] = true;
                    ++$foundChars;
                    $invalid = false;
                }
                if (($i + $size) > $strlen) {
                    $ignoredChars = substr($string, $i);
                    break;
                }
                for ($j = 1; $j < $size; ++$j) {
                    $char = $string[$i + $j];
                    if ($char > "\x7F" && $char < "\xC0") {
                        // Valid - continue parsing
                    } else {
                        /* char is invalid, we must wait for a resync */
                        $invalid = true;
                        continue 2;
                    }
                }
                /* Ok we got a complete char here */
                $currentMap['p'][$charPos + $foundChars] = $startOffset + $i + $size;
                $i += $j - 1;
                ++$foundChars;
            }
        }

        return $foundChars;
    }