Truncate a string and add an optional suffix.

@param string $pStr String to truncate
@param int $pLimit Length of the string to return
@param string $pEnd Suffix
768663
public static function truncate($pStr, $pLimit, $pEnd = '...')
    {
        $str    = strip_tags($pStr);
        $length = mb_strlen($str);
        if ($length <= $pLimit) {
            return $str;
        }

        return trim(mb_substr($str, 0, $pLimit)) . $pEnd;
    }
1289606
public static function truncate($s, $maxlength = null, $continue = "\xe2\x80\xa6", &$is_cutted = null, $tail_min_length = 20)
	{
		return self::str_limit($s, $maxlength, $continue, $is_cutted, $tail_min_length);
	}
523176
public void setLongProperty(String pstrSection, String pstrProp, 
                    			long plngVal, String pstrComments)
    {
        INISection objSec   = null;

        objSec = (INISection) this.mhmapSections.get(pstrSection);
        if (objSec == null)
        {
            objSec = new INISection(pstrSection);
            this.mhmapSections.put(pstrSection, objSec);
        }
        objSec.setProperty(pstrProp, Long.toString(plngVal), pstrComments);
    }
426670
function truncate(string) {
  if (string.length > SEG_LENGTH * 2 + 3) {
    return string.slice(0, SEG_LENGTH) + '...' + string.slice(-SEG_LENGTH);
  }

  return string;
}
1278009
public static function shorten($text, $maxlength = 140, $end = '[...]') {
        $maxlength++;
        if (mb_strlen($text) > $maxlength) {
            $subex = mb_substr($text, 0, $maxlength - 5);
            $exwords = explode(' ', $subex);
            $excut = - (mb_strlen($exwords[count($exwords)-1]));
            if ($excut < 0) {
                $text = mb_substr($subex, 0, $excut);
            } else {
                $text = $subex;
            }
            $text .= $end;
        }
        return $text;
    }
475252
public static long getLong(String pStr) {
        if (isEmpty(pStr)) {
            return 0;
        }
        long value = 0;
        try {
            value = Long.parseLong(pStr);
        } catch (NumberFormatException nm) {
        }
        return value;
    }
811431
public function truncateHtml($html, $length, $ellipsis = '...')
    {
        return $this->truncate(html_entity_decode(strip_tags($html), null, 'UTF-8'), $length, $ellipsis);
    }
916252
public static function truncate_two($str, $start, $length = null)
    {
        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;
    }
738773
public function truncate($text, $length = 15)
    {
        if (!$this->isValidLength($text, $length)) return $text;
        return (\strlen($text) > $length) ? $this->left($text, $length) . '...' : $text;
    }
1261081
public static function truncate($str, $length, $trailing='...') {
		$length -= mb_strlen($trailing);

		if (mb_strlen($str) > $length)
			return mb_substr($str,0,$length).$trailing;
		return $str;
	}
614170
public static String truncate(String str, int count)
    {
        if(count < 0 || str.length() <= count)
            return str;

        int pos = count;
        for(int i = count; i >= 0 && !Character.isWhitespace(str.charAt(i)); i--, pos--);
        return str.substring(0, pos)+"...";
    }
36884
def truncate(string, count=30)
      if string.length >= count
        shortened = string[0, count]
        splitted = shortened.split(/\s/)
        words = splitted.length
        splitted[0, words - 1].join(' ') + '...'
      else
        string
      end
    end
1204322
def truncate(str, length, options = {})
      text = str.dup
      options[:omission] ||= "..."

      length_with_room_for_omission = length - options[:omission].length
      stop = options[:separator] ?
        (text.rindex(options[:separator], length_with_room_for_omission) || length_with_room_for_omission) : length_with_room_for_omission

      (text.length > length ? text[0...stop] + options[:omission] : text).to_s
    end
987570
def truncate(string, length, ellipsis="…"):
    
    if len(string) > length:
        return string[: length - len(ellipsis)] + ellipsis
    return string
1070671
public static function truncate($str, $maxlength=20)
    {

        if(strlen($str) > $maxlength){
            $str = substr($str, 0, $maxlength-3).'...';
        }

        return $str;
    }
685034
def truncate(string, width, options={})
      trailing = options[:trailing] || '…'

      chars = string.to_s.chars.to_a
      if chars.length < width && chars.length > 3
        chars.join
      elsif chars.length > 3
        (chars[0, width - trailing.length].join) + trailing
      end
    end
1311613
public function truncate($length)
    {
        $this->_text = StringHelper::truncate($this->_text, $length);
        
        return $this;
    }