protected function substring($length, $caseSensitive = true, $offset = null)
    {
        if ($offset === null) {
            $offset = $this->offset;
        }
        if ($offset + $length > $this->length) {
            return '';
        }

        $cacheKey = $offset . ',' . $length;
        if (!isset($this->_substrings[$cacheKey . ',1'])) {
            $this->_substrings[$cacheKey . ',1'] = mb_substr($this->sql, $offset, $length, 'UTF-8');
        }
        if (!$caseSensitive && !isset($this->_substrings[$cacheKey . ',0'])) {
            $this->_substrings[$cacheKey . ',0'] = mb_strtoupper($this->_substrings[$cacheKey . ',1'], 'UTF-8');
        }

        return $this->_substrings[$cacheKey . ',' . (int) $caseSensitive];
    }