Returns part of a string.

@param  integer $start
@param  integer $length
@return TeamSpeak3_Helper_String
192452
public function substr($start, $length = null)
  {
    $string = ($length !== null) ? substr($this->string, $start, $length) : substr($this->string, $start);

    return new self($string);
  }
465264
public static function substr($str, $start, $length, $suffix = false) {
        if (mb_strlen($str, 'utf-8') <= $length) return $str;
        $slice = mb_substr($str, $start, $length, 'utf-8');
		if ($suffix) return $slice."…";
		return $slice;
	}
33121
public static function Substring ($string, $start, $length = null, $encoding = Encoding::DEFAULT_ENCODING) {
		if ($length === null) {
			$length = self::Length($string) - $start;
		}
		return mb_substr($string, $start, $length, $encoding);
	}
997418
static public function msubstr($str, $start=0, $length, $charset="utf-8", $suffix=true) {
        if(function_exists("mb_substr"))
            $slice = mb_substr($str, $start, $length, $charset);
        elseif(function_exists('iconv_substr')) {
            $slice = iconv_substr($str,$start,$length,$charset);
        }else{
            $re['utf-8']   = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/";
            $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/";
            $re['gbk']    = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/";
            $re['big5']   = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/";
            preg_match_all($re[$charset], $str, $match);
            $slice = join("",array_slice($match[0], $start, $length));
        }
        return $suffix ? $slice.'...' : $slice;
    }
310797
public function at($start = null, $length = null)
    {
        return new String(mb_substr((string) $this, $start, $length, 'UTF-8'));
    }
231642
public function transform(string $value, int $start = 0, int $length = null): string {
        return $length === null ? substr($value, $start) : substr($value, $start, $length);
    }
1251037
public function get( $prompt = "", $length = 1024 ){
		remark( $prompt );
		ob_flush();
		$result = trim( fgets( $this->tty, $length ) );
		return $result;
	}
1275481
public function slice($start, $length = null)
    {
        $answer = new HArraySlice($this);
        return new static($answer->slice($start, $length));
    }
360804
public function substr($start = 0, $length = null)
    {
        $function = static::$functions[(int) static::$useMbstring]['substr'];

        return new self($function($this->string, $start, $length));
    }
1316806
private static function substr($str,$start,$length=null)
    {
        $ar = array();
        preg_match_all("/./u", $str, $ar);

        if($length != null) {
            return join("",array_slice($ar[0],$start,$length));
        } else {
            return join("",array_slice($ar[0],$start));
        }
    }
465902
public static function SubstringWithLength( $item, $startingLoc, $length )
	{
		if ( $item instanceof Undefined )
		{
			return "";
		}

		$value = (string)$item; // . "";

		if ( $startingLoc instanceof XPath2Item )
		{
			$startingLoc = $startingLoc->getTypedValue();
		}

		if ( $length instanceof XPath2Item )
		{
			$length = $length->getTypedValue();
		}

		if ( $startingLoc == INF ||  $startingLoc == -INF || is_nan( $startingLoc ) || $length == -INF || is_nan( $length ) )
		{
			return "";
		}

		$pos = intval( Round( $startingLoc ) ) - 1;
		$len;
		if ( $length == INF )
		    $len = PHP_INT_MAX;
		else
		    $len = intval( Round( $length ) );

		if ( $pos < 0 )
		{
		    $len = $len + $pos;
		    $pos = 0;
		}

		if ( $pos < strlen( $value ) )
		{
		    if ( $pos + $len > strlen( $value ) )
			   $len = strlen( $value ) - $pos;

		    if ( $len > 0 )
			   return substr( $value, $pos, $len );
		}
		return "";
	}
336257
public static function stringCute($string, $start = 0, $end = null): string
    {
        if (!\is_string($string)) {
            return '';
        }

        // $length    = Helper::strlen($string);
        return self::subStr($string, $start, $end);
    }
859331
public static function startWith(string $string, string $start): bool
    {
        return substr($string, 0, strlen($start)) === $start;
    }
760799
public function substring($start, $end = null)
    {
        if ($end === null) {
            return substr($this->content, $start);
        }
        $len = $end - $start;
        if ($len < 0) {
            return '';
        }
        return substr($this->content, $start, $len);
    }
1158037
public function readToken($start)
    {
        $length = $this->source->getLength();
        $position = $this->positionAfterWhitespace($start);

        if ($position >= $length) {
            return new Token(Token::EOF_TYPE, $length, $length);
        }

        $code = $this->charCodeAt($position);

        switch ($code) {
            // !
            case 33:
                return new Token(Token::BANG_TYPE, $position, $position + 1);
            // $
            case 36:
                return new Token(Token::DOLLAR_TYPE, $position, $position + 1);
            // (
            case 40:
                return new Token(Token::PAREN_L_TYPE, $position, $position + 1);
            // )
            case 41:
                return new Token(Token::PAREN_R_TYPE, $position, $position + 1);
            // .
            case 46:
                if ($this->charCodeAt($position + 1) === 46 && $this->charCodeAt($position + 2) === 46) {
                    return new Token(Token::SPREAD_TYPE, $position, $position + 3);
                }
                break;
            // :
            case 58:
                return new Token(Token::COLON_TYPE, $position, $position + 1);
            // =
            case 61:
                return new Token(Token::EQUALS_TYPE, $position, $position + 1);
            // @
            case 64:
                return new Token(Token::AT_TYPE, $position, $position + 1);
            // [
            case 91:
                return new Token(Token::BRACKET_L_TYPE, $position, $position + 1);
            // ]
            case 93:
                return new Token(Token::BRACKET_R_TYPE, $position, $position + 1);
            // {
            case 123:
                return new Token(Token::BRACE_L_TYPE, $position, $position + 1);
            // |
            case 124:
                return new Token(Token::PIPE_TYPE, $position, $position + 1);
            // }
            case 125:
                return new Token(Token::BRACE_R_TYPE, $position, $position + 1);
            // A-Z
            case 65: case 66: case 67: case 68: case 69: case 70: case 71: case 72:
            case 73: case 74: case 75: case 76: case 77: case 78: case 79: case 80:
            case 81: case 82: case 83: case 84: case 85: case 86: case 87: case 88:
            case 89: case 90:
            // _
            case 95:
            // a-z
            case 97: case 98: case 99: case 100: case 101: case 102: case 103: case 104:
            case 105: case 106: case 107: case 108: case 109: case 110: case 111:
            case 112: case 113: case 114: case 115: case 116: case 117: case 118:
            case 119: case 120: case 121: case 122:
                return $this->readName($position);
            // -
            case 45:
            // 0-9
            case 48: case 49: case 50: case 51: case 52:
            case 53: case 54: case 55: case 56: case 57:
                return $this->readNumber($position, $code);
            // "
            case 34:
                return $this->readString($position);
        }

        // @todo Throw proper exception.
        throw new \Exception('Unexpected character.');
    }
1097681
public static function substr($string, $start, $length = null)
    {
        return mb_substr($string, $start, $length, self::ENCODING);
    }
1265848
public static function truncate2(string $str, int $start, int $length = null): string
    {
        if (!$length) {
            $length = $start;
            $start  = 0;
        }

        if (\strlen($str) <= $length) {
            return $str;
        }

        if (\function_exists('mb_substr')) {
            $str = \mb_substr(\strip_tags($str), $start, $length, 'utf-8');
        } else {
            $str = \substr($str, $start, $length) . '...';
        }

        return $str;
    }