Concat char's in string.     *
@param string $value
@param int $length
@param string $endChars
@return string $value
424228
public static function fixStringLength($value, $length, $endChars = '...')
    {
        if (!empty($value) and !empty($length)) {
            $cutLen = (int) $length - (int) strlen($endChars);
            if (strlen($value) > $length) {
                $strCut = substr($value, 0, $cutLen);
                $value = $strCut . $endChars;
            }
        }
        return $value;
    }
581990
public function prepare($text, $length = 100, $endString = '...')
    {
        $substring = strip_tags(preg_replace('/<br.?\/?>/', ' ',$text));
        $textLength = mb_strlen($substring);
        
        if($textLength > $length) {
            $lastWordPosition = mb_strpos($substring, ' ', $length);
            
            if($lastWordPosition) {
                $substring = mb_substr($substring, 0, $lastWordPosition);
            } else {
                $substring = mb_substr($substring, 0, $length);
            }
            
            $substring.= $endString;
        }
        
        return $substring;
    }
749353
public function replace($start, $end, $value)
    {
        for ($i = $start; $i <= $end - $start; $i++) {
            $this->sequence[(int) $i] = $value;
        }

        return $this;
    }
277422
private static function preserveBreakpoint($value, $length)
    {
        if (strlen($value) <= $length) {
            return $length;
        }
        $breakpoint = mb_strpos($value, ' ', $length);
        $length = $breakpoint;
        if (false === $breakpoint) {
            $length = mb_strlen($value);
        }
        return $length;
    }
940844
private static void endsWith(StringBuilder sb, String attr, String value) {
        sb.append("'");
        sb.append(value.replace("'", "\\'"));
        sb.append("' = substring(@");
        sb.append(attr);
        sb.append(", string-length(@");
        sb.append(attr);
        sb.append(") - string-length('");
        sb.append(value.replace("'", "\\'"));
        sb.append("') + 1)");
    }
1278683
public static String concat(String[] parts, char character) {
    StringBuilder stringBuilder = new StringBuilder();

    for (String part : parts) {
      stringBuilder.append(part).append(character);
    }

    stringBuilder.deleteCharAt(stringBuilder.length() - 1);

    return stringBuilder.toString();
  }
924361
public static function truncateValue($string, $limit, $endchars = '...')
    {

        if (!is_array($string) && !is_object($string)) {
            $stringLength = strlen($string);
            $endcharsLength = strlen($endchars);

            if ($stringLength > (int) $limit) {
                $cut = (int) ($limit - $endcharsLength);
                $string = substr($string, 0, $cut) . $endchars;
            }
        }
        return $string;
    }
253608
public static function LEFT($value = '', $chars = 1)
    {
        $value = PHPExcel_Calculation_Functions::flattenSingleValue($value);
        $chars = PHPExcel_Calculation_Functions::flattenSingleValue($chars);

        if ($chars < 0) {
            return PHPExcel_Calculation_Functions::VALUE();
        }

        if (is_bool($value)) {
            $value = ($value) ? PHPExcel_Calculation::getTRUE() : PHPExcel_Calculation::getFALSE();
        }

        if (function_exists('mb_substr')) {
            return mb_substr($value, 0, $chars, 'UTF-8');
        } else {
            return substr($value, 0, $chars);
        }
    }
1123328
public static function removeChar($string, $offset, $length = null, $encoding = null)
    {
        $encoding = $encoding === null ? mb_internal_encoding() : $encoding;

        if (Mbstring::strlen($string, $encoding) < abs($offset)) {
            return $string;
        }

        $length = $length === null ? 1 : $length;

        return Mbstring::substrReplace($string, '', $offset, $length, $encoding);
    }
540207
public static function truncate($value, array $params)
    {
        if (empty($params['length']) || !is_numeric($params['length'])) {
            $params['length'] = 4;
        }

        return StringHelper::truncate($value, (int)$params['length']);
    }
456256
public function fill($value, $start = null, $end = null)
    {
        $array = $this->getArrayCopy();
        $length = $this->length();

        if ($end <= 0) {
            $end = $length - $end;
        }

        if (is_null($start) === true) {
            $i = $end ?: $length;

            while ($i--) {
                $array[$i] = $value;
            }
        }

        if ($start <= 0) {
            $start = $length - $start;
        }

        $end = $end ?: $length;
        $i = $start;

        while ($i !== $end) {
            $array[$i] = $value;
            $i++;
        }

        return new static($array);
    }
875256
public function truncate($string, $endlength="30", $end="...")
        {
            $strlen = strlen($string);

            if ($strlen > $endlength) {
                $trim = $endlength - $strlen;
                $string = substr($string, 0, $trim);
                $string .= $end;
            }

            return $string;
        }
1274164
protected function _exportParamValue($value = null, $length = 0) {
		$truncateOpt = [
			'ellipsis' => '...',
			'exact' => false,
			'html' => false
		];

		$valueText = var_export($value, true);
		$valueType = Debugger::getType($value);
		switch ($valueType) {
			case 'string':
				if (ctype_digit($value)) {
					$valueText = (int)$value;
				}
				break;
			case 'resource':
			case 'unknown':
				$valueText = 'null';
				break;
		}
		if ($length > 0) {
			$valueText = CakeText::truncate($valueText, $length, $truncateOpt);
		}

		return $valueText;
	}
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);
    }
1291700
public static function convertFromOutOfRangeChars($value)
    {
        $values = str_split($value);
        foreach ($values as $item) {
            if (ord($item) >= 127) {
                $value = str_replace($item, ' ', $value);
            }
        }

        return $value;
    }
1171850
public static function char(String $str, Int $limit = 500, String $endChar = '...',  Bool $stripTags = false, String $encoding = "utf-8") : String
    {
        $str = trim($str);

        if( $stripTags === true )
        {
            $str = strip_tags($str);
        }

        $str = preg_replace("/\s+/", ' ', str_replace(["\r\n", "\r", "\n", "&nbsp;"], ' ', $str));

        if( mb_strlen($str, $encoding) <= $limit )
        {
            return $str;
        }
        else
        {
            return mb_substr($str, 0, $limit, $encoding).$endChar;
        }
    }
571206
protected function encodeString($value, $length = -1) {
        if (-1 !== $length && $length < strlen($value)) {
            throw new TooLongDataException($value, $length);
        }
        return "\"" . substr($value, 0, (-1 === $length ? strlen($value) : $length)) . "\"";
    }