Pay attantion to this output
@see http://climate.thephpleague.com/terminal-objects/flank/

@param  string $output Output string
@param  string $char   Special character
@param  int    $length Character length
@return mixed
490410
public function flank($output, $char = null, $length = null)
    {
        return $this->climate->flank($output, $char, $length);
    }
119170
public static function getRandomString(int $length = 32, string $characters = 'qwertyuiopasdfghjklzxcvbnm0123456789'): string
    {
        $max = mb_strlen($characters, 'utf-8') - 1;
        $string = '';

        for ($i = 0; $i < $length; ++$i) {
            $string .= mb_substr($characters, random_int(0, $max), 1, 'utf-8');
        }

        return $string;
    }
900128
public function char($column, $length = null)
    {
        $length = $length ?: Builder::$defaultStringLength;

        return $this->addColumn('char', $column, compact('length'));
    }
1251037
public function get( $prompt = "", $length = 1024 ){
		remark( $prompt );
		ob_flush();
		$result = trim( fgets( $this->tty, $length ) );
		return $result;
	}
465795
public String readUntil(char c) throws IOException {
        if (lookaheadChar == UNDEFINED) {
            lookaheadChar = super.read();
        }
        line.clear(); // reuse
        while (lookaheadChar != c && lookaheadChar != END_OF_STREAM) {
            line.append((char) lookaheadChar);
            if (lookaheadChar == '\n') {
                lineCounter++;
            }
            lastChar = lookaheadChar;
            lookaheadChar = super.read();
        }
        return line.toString();
    }
548896
protected function readStream(&$stream, &$output) {
    $content = stream_get_contents($stream);
    if (strlen(rtrim($content))) {
      foreach (preg_split('/\r?\n/', $content) as $line) {
        $output[] = $line;
      }
    }
  }
908254
public function translateChar($char, $use_default = true)
    {
        $dec = hexdec(bin2hex($char));

        if (array_key_exists($dec, $this->table)) {
            $char = $this->table[$dec];
        } else {
            $char = ($use_default ? self::MISSING : $char);
        }

        return $char;
    }
1286274
public static function stringTrim(string $string, int $length): string
    {
        if ($length<16) return $string;
        if (strlen($string)>$length) {
            $str_head = substr($string, 0, $length-10);
            $str_tail = substr($string, -7, 7);
            return $str_head.'...'.$str_tail;
        }
        return $string;
    }
916833
public static function compare($charA, $charB): int
    {
        self::handleIncomingChar($charA, $charB);

        return (string) $charA <=> (string) $charB;
    }
344428
public static function toUnicodeCodepoint($char)
    {
        $charCode = false;
        // 7bits, 1 char
        if ((ord($char[0]) & 0x80) == 0x00) {
            $charCode = ord($char[0]);
        } elseif ((ord($char[0]) & 0xe0) == 0xc0) { // 11 bits, 2 chars
            if ((ord($char[1]) & 0xc0) != 0x80) {
                return $charCode;
            }

            $charCode = (
                ((ord($char[0]) & 0x1f) << 6) +
                ((ord($char[1]) & 0x3f))
            );

            if ($charCode < 128) {
                throw new RuntimeException('Illegal UTF-8 input character: ' . $char);
            }
        } elseif ((ord($char[0]) & 0xf0) == 0xe0) { // 16 bits, 3 chars
            if ((ord($char[1]) & 0xc0) != 0x80 ||
                 (ord($char[2]) & 0xc0) != 0x80) {
                return $charCode;
            }
            $charCode = (
                ((ord($char[0]) & 0x0f) << 12) +
                ((ord($char[1]) & 0x3f) << 6) +
                ((ord($char[2]) & 0x3f))
            );

            if ($charCode < 2048) {
                throw new RuntimeException('Illegal UTF-8 input character: ' . $char);
            }
        } elseif ((ord($char[0]) & 0xf8) == 0xf0) { // 21 bits, 4 chars
            if ((ord($char[1]) & 0xc0) != 0x80 ||
                 (ord($char[2]) & 0xc0) != 0x80 ||
                 (ord($char[3]) & 0xc0) != 0x80) {
                return $charCode;
            }

            $charCode = (
                ((ord($char[0]) & 0x07) << 18) +
                ((ord($char[1]) & 0x3f) << 12) +
                ((ord($char[2]) & 0x3f) << 6) +
                ((ord($char[3]) & 0x3f))
            );

            if ($charCode < 65536) {
                throw new RuntimeException('Illegal UTF-8 input character: ' . $char);
            }
        } elseif ((ord($char[0]) & 0xfc) == 0xf8) { // 26 bits, 5 chars
            if ((ord($char[1]) & 0xc0) != 0x80 ||
                 (ord($char[2]) & 0xc0) != 0x80 ||
                 (ord($char[3]) & 0xc0) != 0x80 ||
                 (ord($char[4]) & 0xc0) != 0x80) {
                return $charCode;
            }

            $charCode = (
                ((ord($char[0]) & 0x03) << 24) +
                ((ord($char[1]) & 0x3f) << 18) +
                ((ord($char[2]) & 0x3f) << 12) +
                ((ord($char[3]) & 0x3f) << 6) +
                ((ord($char[4]) & 0x3f))
            );

            if ($charCode < 2097152) {
                throw new RuntimeException('Illegal UTF-8 input character: ' . $char);
            }
        } elseif ((ord($char[0]) & 0xfe) == 0xfc) { // 31 bits, 6 chars
            if ((ord($char[1]) & 0xc0) != 0x80 ||
                 (ord($char[2]) & 0xc0) != 0x80 ||
                 (ord($char[3]) & 0xc0) != 0x80 ||
                 (ord($char[4]) & 0xc0) != 0x80 ||
                 (ord($char[5]) & 0xc0) != 0x80) {
                return $charCode;
            }

            $charCode = (
                ((ord($char[0]) & 0x01) << 30) +
                ((ord($char[1]) & 0x3f) << 24) +
                ((ord($char[2]) & 0x3f) << 18) +
                ((ord($char[3]) & 0x3f) << 12) +
                ((ord($char[4]) & 0x3f) << 6) +
                ((ord($char[5]) & 0x3f))
            );

            if ($charCode < 67108864) {
                throw new RuntimeException('Illegal UTF-8 input character: ' . $char);
            }
        }

        return $charCode;
    }
1000962
public static function ord($char, &$bytes = null)
    {
        // Get the first byte from char
        $firstByte = substr($char, 0, 1);
        $firstByteCode = ord($firstByte);

        $bytes = 0;

        while ($firstByteCode >> 7 & 0x01) {
            $bytes++;
            $firstByteCode <<= 1;
        }

        if ($bytes === 0) {
            // 0b0xxxxxxx
            return ord($firstByte);
        }

        // Create a unicode ord
        $unicodeOrd = ((ord($firstByte) << ($bytes + 1)) & 0xFF) >> ($bytes + 1);

        for ($i = 1; $i < $bytes; $i++) {
            // Shift unicode byte to left on 6 position (0b10xxxxxx)
            $unicodeOrd <<= 6;
            $byte = ord(substr($char, $i, 1)) & 0b00111111;
            $unicodeOrd |= $byte;
        }

        return $unicodeOrd;
    }
575365
public static function format_flowed($text, $length = 72, $charset=null)
    {
        $text = preg_split('/\r?\n/', $text);

        foreach ($text as $idx => $line) {
            if ($line != '-- ') {
                if ($level = strspn($line, '>')) {
                    // remove quote chars
                    $line = substr($line, $level);
                    // remove (optional) space-staffing and spaces before the line end
                    $line = rtrim($line, ' ');
                    if ($line[0] === ' ') $line = substr($line, 1);

                    $prefix = str_repeat('>', $level) . ' ';
                    $line   = $prefix . self::wordwrap($line, $length - $level - 2, " \r\n$prefix", false, $charset);
                }
                else if ($line) {
                    $line = self::wordwrap(rtrim($line), $length - 2, " \r\n", false, $charset);
                    // space-stuffing
                    $line = preg_replace('/(^|\r\n)(From| |>)/', '\\1 \\2', $line);
                }

                $text[$idx] = $line;
            }
        }

        return implode("\r\n", $text);
    }
973305
protected function charToCodePoint($char)
    {
        $code = ord($char[0]);
        if ($code < 128) {
            return $code;
        } elseif ($code < 224) {
            return (($code - 192) * 64) + (ord($char[1]) - 128);
        } elseif ($code < 240) {
            return (($code - 224) * 4096) + ((ord($char[1]) - 128) * 64) + (ord($char[2]) - 128);
        } else {
            return (($code - 240) * 262144) + ((ord($char[1]) - 128) * 4096) + ((ord($char[2]) - 128) * 64) + (ord($char[3]) - 128);
        }
    }
1213418
public function read($length)
    {
        // let Guzzle decide what to do.
        if ($length <= 0 || $this->eof()) {
            return $this->stream->read($length);
        }
        $this->readRawCharsIntoBuffer($length);
        $numChars = min([$this->bufferLength, $length]);
        $chars = $this->converter->getSubstr($this->buffer, $this->streamCharset, 0, $numChars);
        
        $this->position += $numChars;
        $this->buffer = $this->converter->getSubstr($this->buffer, $this->streamCharset, $numChars);
        $this->bufferLength = $this->bufferLength - $numChars;

        return $this->converter->convert($chars, $this->streamCharset, $this->stringCharset);
    }
301318
public static function getPrefix($str, $length)
    {
        $prefixBytes = 0;
        $prefixChars = 0;
        while ($prefixBytes < strlen($str)  &&  $prefixChars < $length) {
            $charBytes = 1;
            if ((ord($str[$prefixBytes]) & 0xC0) == 0xC0) {
                $charBytes++;
                if (ord($str[$prefixBytes]) & 0x20 ) {
                    $charBytes++;
                    if (ord($str[$prefixBytes]) & 0x10 ) {
                        $charBytes++;
                    }
                }
            }

            if ($prefixBytes + $charBytes > strlen($str)) {
                // wrong character
                break;
            }

            $prefixChars++;
            $prefixBytes += $charBytes;
        }

        return substr($str, 0, $prefixBytes);
    }
355294
public function sendOutput(String $output, String $colour='white', String $backgroundColor='black')
	{
		fwrite(STDOUT, $this->getText($output, $colour, $backgroundColor));
	}
471925
private function _negotiate($char) {
        switch ($char) {
            case TEL_DO:
                $this->_negotiateDo(fgetc($this->_sock));
                break;
            case TEL_WILL:
                $this->_negotiateWill(fgetc($this->_sock));
                break;
        }
    }