@param string $text
@param bool   $unicode

@return string
192032
protected function decodeContent($text, &$unicode)
    {
        if ($this->has('ToUnicode')) {

            $bytes = $this->tableSizes['from'];

            if ($bytes) {
                $result = '';
                $length = strlen($text);

                for ($i = 0; $i < $length; $i += $bytes) {
                    $char = substr($text, $i, $bytes);

                    if (($decoded = $this->translateChar($char, false)) !== false) {
                        $char = $decoded;
                    } elseif ($this->has('DescendantFonts')) {

                        if ($this->get('DescendantFonts') instanceof PDFObject) {
                            $fonts   = $this->get('DescendantFonts')->getHeader()->getElements();
                        } else {
                            $fonts   = $this->get('DescendantFonts')->getContent();
                        }
                        $decoded = false;

                        foreach ($fonts as $font) {
                            if ($font instanceof Font) {
                                if (($decoded = $font->translateChar($char, false)) !== false) {
                                    $decoded = mb_convert_encoding($decoded, 'UTF-8', 'Windows-1252');
                                    break;
                                }
                            }
                        }

                        if ($decoded !== false) {
                            $char = $decoded;
                        } else {
                            $char = mb_convert_encoding($char, 'UTF-8', 'Windows-1252');
                        }
                    } else {
                        $char = self::MISSING;
                    }

                    $result .= $char;
                }

                $text = $result;

                // By definition, this code generates unicode chars.
                $unicode = true;
            }
        } elseif ($this->has('Encoding')) {
            /** @var Encoding $encoding */
            $encoding = $this->get('Encoding');

            if ($encoding instanceof Encoding) {
                if ($unicode) {
                    $chars  = preg_split(
                        '//s' . ($unicode ? 'u' : ''),
                        $text,
                        -1,
                        PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY
                    );
                    $result = '';

                    foreach ($chars as $char) {
                        $dec_av = hexdec(bin2hex($char));
                        $dec_ap = $encoding->translateChar($dec_av);
                        $result .= self::uchr($dec_ap);
                    }

                    $text = $result;
                } else {
                    $result = '';
                    $length = strlen($text);

                    for ($i = 0; $i < $length; $i++) {
                        $dec_av = hexdec(bin2hex($text[$i]));
                        $dec_ap = $encoding->translateChar($dec_av);
                        $result .= chr($dec_ap);
                    }

                    $text = $result;

                    if ($encoding->get('BaseEncoding')->equals('MacRomanEncoding')) {
                        $text = mb_convert_encoding($text, 'UTF-8', 'Mac');

                        return $text;
                    }
                }
            }
        }

        // Convert to unicode if not already done.
        if (!$unicode) {

            if ($this->get('Encoding') instanceof Element &&
                $this->get('Encoding')->equals('MacRomanEncoding')
            ) {
                $text = mb_convert_encoding($text, 'UTF-8', 'Mac');
            } else {
                $text = mb_convert_encoding($text, 'UTF-8', 'Windows-1252');
            }
        }

        return $text;
    }
1262947
public static function stderr($text, $raw = false)
    {
        if ($raw) {
            return fwrite(STDERR, $text);
        } elseif (extension_loaded('posix') && posix_isatty(STDERR)) {
            return fwrite(STDERR, static::colorize($text));
        } else {
            return fwrite(STDERR, static::decolorize($text));
        }
    }
1301986
public static function stripInvalidUTF8Chars($text)
    {
        $ret = '';
        $current;
        if (empty($text))
        {
            return $ret;
        }

        $length = strlen($text);
        for ($i=0; $i < $length; $i++)
        {
            $current = ord($text{$i});
            if (($current == 0x9) ||
                ($current == 0xA) ||
                ($current == 0xD) ||
                (($current >= 0x20) && ($current <= 0xD7FF)) ||
                (($current >= 0xE000) && ($current <= 0xFFFD)) ||
                (($current >= 0x10000) && ($current <= 0x10FFFF)))
            {
                $ret .= chr($current);
            }
            else
            {
                $ret .= '⍰';
            }
        }

        return $ret;
    }
645469
public static function decodeUnicode($text)
    {
        if (preg_match('/^\xFE\xFF/i', $text)) {
            // Strip U+FEFF byte order marker.
            $decode = substr($text, 2);
            $text   = '';
            $length = strlen($decode);

            for ($i = 0; $i < $length; $i += 2) {
                $text .= self::uchr(hexdec(bin2hex(substr($decode, $i, 2))));
            }
        }

        return $text;
    }
552286
public function confirm($text)
    {
        $helper = $this->getHelper('question');

        $question = new ConfirmationQuestion($text, false);

        return $helper->ask($this->input, $this->getOutputInterface(), $question);
    }
855826
public static function strlen($text, $charset='utf-8') {
        $charset = self::parse_charset($charset);

        if ($charset === 'utf-8') {
            if (function_exists('mb_strlen')) {
                return mb_strlen($text, 'UTF-8');
            } else {
                return iconv_strlen($text, 'UTF-8');
            }
        }

        $oldlevel = error_reporting(E_PARSE);
        $result = self::typo3()->strlen($charset, (string)$text);
        error_reporting($oldlevel);

        return $result;
    }
692610
public function read(&$text)
    {
        if (preg_match_all('#@template\(\'(.*)\'#siU', $text, $matches)) {
            foreach ($matches[1] as $key => $match) {
                if (is_string($match) && strpos($match, '.') === false) {
                    $path =  dirname($this->getTemplate()->getPath()).DS.$match.'.php';
                    $text = str_replace($matches[0][$key], '$this->loadFile('."'".$path."'", $text);
                }
            }
        }

        return $this;
    }
668494
private function decode($text) {
		$pad = ord(substr($text, -1));
		if ($pad < 1 || $pad > 32) {
			$pad = 0;
		}

		return substr($text, 0, (strlen($text) - $pad));
	}
1272664
public function parse(string $text) : string
    {
        if ($text === '')
            throw new ParseException($this, $text, 0, self::NO_EMPTY);
        return $text;
    }
1007413
public function text($text) {

        if(false === is_string($text)) {
            return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string, "%s" given', __METHOD__, gettype($text)), E_USER_ERROR);
        }

    	$this -> text = $text;

    	return $this;
    }
256735
public static function strtoupper($text) {
    if (static::getStatus() == static::STATUS_MULTIBYTE) {
      return mb_strtoupper($text);
    }
    else {
      // Use C-locale for ASCII-only uppercase.
      $text = strtoupper($text);
      // Case flip Latin-1 accented letters.
      $text = preg_replace_callback('/\xC3[\xA0-\xB6\xB8-\xBE]/', '\Drupal\Component\Utility\Unicode::caseFlip', $text);
      return $text;
    }
  }
116440
function filterText($text, $bom = true, $convert_encoding = true)
    {
        if (!$this->numFonts) {
            $this->selectFont($this->defaultFont);
        }

        if ($convert_encoding) {
            $cf = $this->currentFont;
            if (isset($this->fonts[$cf]) && $this->fonts[$cf]['isUnicode']) {
                $text = $this->utf8toUtf16BE($text, $bom);
            } else {
                //$text = html_entity_decode($text, ENT_QUOTES);
                $text = mb_convert_encoding($text, self::$targetEncoding, 'UTF-8');
            }
        } else if ($bom) {
            $text = $this->utf8toUtf16BE($text, $bom);
        }

        // the chr(13) substitution fixes a bug seen in TCPDF (bug #1421290)
        return strtr($text, array(')' => '\\)', '(' => '\\(', '\\' => '\\\\', chr(13) => '\r'));
    }
866405
static function strtolower( $text )
    {
        //We need to detect our internal charset
        if ( self::$charset === null )
        {
            self::$charset = eZTextCodec::internalCharset();
        }

        //First try to use mbstring
        if ( extension_loaded( 'mbstring' ) )
        {
            return mb_strtolower( $text, self::$charset );
        }
        else
        {
            // Fall back if mbstring is not available
            $char = eZCharTransform::instance();
            return $char->transformByGroup( $text, 'lowercase' );
        }
    }
227040
protected function confirm($text, $default = true)
    {
        $choices = $default ? 'Yn' : 'yN';
        $confirm = new ConfirmationQuestion("$text [$choices] ", $default);

        return $this->getHelper('question')->ask($this->input, $this->output, $confirm);
    }
580921
public function parse(string $text) : bool
    {
        $lower = strtolower($text);
        if (! in_array($lower, array_merge(self::TRUE_VALUES, self::FALSE_VALUES)))
            throw new ParseException($this, $text, 0, self::PARSE_ERROR);
        return in_array($lower, self::TRUE_VALUES);
    }
213267
public static function stdout($text, $raw = false)
    {
        if ($raw) {
            return fwrite(STDOUT, $text);
        } elseif (extension_loaded('posix') && posix_isatty(STDOUT)) {
            return fwrite(STDOUT, static::colorize($text));
        } else {
            return fwrite(STDOUT, static::decolorize($text));
        }
    }
1326969
function convertText( $text, $isHeader = false )
    {

        $charset = $this->contentCharset();
        if ( $this->isAllowedCharset( $charset ) )
            return $text;
        $outputCharset = $this->outputCharset();
        if ( !$this->TextCodec )
        {
            $this->TextCodec = eZTextCodec::instance( $charset, $outputCharset );
        }
        $newText = $this->TextCodec->convertString( $text );
        return $newText;
    }