Uses either mb_strlen or iconv_strlen to return the number of characters
in the passed $str for the given $charset

@param string $str
@param string $charset
@return int
557257
public function getLength($str, $charset)
    {
        $mb = $this->getMbCharset($charset);
        if ($mb !== false) {
            return mb_strlen($str, $mb);
        }
        return iconv_strlen($str, $this->getIconvAlias($charset));
    }
1071024
private static function mb_ucfirst( $str ) {
		if ( ! is_string( $str ) || '' === $str) { return ''; }
		$first = mb_strtoupper( mb_substr( $str, 0, 1 ) );
		if ( 1 === mb_strlen( $str ) ) { return $first; }
		return $first . mb_substr( $str, 1 );
	}
116556
public function mbStrLen($string, $encoding = null)
    {
        // Meh, the original mb_strlen interprets a null here as an empty string.
        if ($encoding === null) {
            return mb_strlen($string);
        }
        return mb_strlen($string, $encoding);
    }
752980
public function HasMultiBytes($str) {
    if (function_exists('mb_strlen')) {
      return (strlen($str) > mb_strlen($str, $this->CharSet));
    } else { // Assume no multibytes (we can't handle without mbstring functions anyway)
      return false;
    }
  }
1099759
public function rtrim($str, $charlist = null)
    {
        return isset($charlist) ? rtrim($str, $charlist) : rtrim($str);
    }
205854
static function Length(&$text,$charset){
		$charset = self::_GetCharsetByName($charset);
		switch($charset){
			case "utf8":
				return self::_LengthUtf8($text);
			default:
				return strlen($text);
		}
	}
1038627
public static function strlen($string, $charset = self::UTF8)
	{
		switch (strtolower($charset))
		{
			case self::GBK:
				$count = self::strlenForGbk($string);
				break;
			case self::UTF8:
				$count = self::strlenForUtf8($string);
				break;
			default:
				$count = strlen($string);
		}
		return $count;
	}
510846
public function ltrim($str, $charlist = null)
    {
        return isset($charlist) ? ltrim($str, $charlist) : ltrim($str);
    }
680854
public static function strlen($str) {
    if (is_array($str))
      return false;

    if (function_exists('mb_strlen'))
      return mb_strlen($str, 'UTF-8');

    return strlen($str);
  }
1338812
private function getCharIndex(string $char): int {
        if (\strlen($char) > 1) $char = \substr($char, 0, 1);
        return \ord($char) - \ord('a');
    }
760670
public static function toLower($str)
    {
        return self::$use_mbstring
            ? mb_strtolower($str, self::$char_set)
            : strtolower($str);
    }
425246
public function str($len, $_charset = null) {
    if($_charset == null) {
      $_charset = $this->_charset;
    }

    $str = '';
    for ($i = 0; $i < $len; $i++) {
      $pos = $this->int(0,strlen($_charset)-1);
      $str .= $_charset[$pos];
    }
    return $str;
  }
1182403
public static function strrev($str)
    {
        $result = '';
        $strLen = static::length($str);

        if (!$strLen) {
            return $result;
        }

        for ($i = $strLen - 1; $i >= 0; $i--) {
            $result .= static::substr($str, $i, 1);
        }

        return $result;
    }
979081
public function count($substring = null) {
		if ($substring === null) {
			return mb_strlen($this->rawString, $this->charset);
		}
		else {
			return mb_substr_count($this->rawString, $substring, $this->charset);
		}
	}
374891
function utf8_to_entities($str) {
		$strLen = strlen($str);
		$outStr = '';
		$buf = '';
		for ($a = 0; $a < $strLen; $a++) { // Traverse each char in UTF-8 string.
			$chr = substr($str, $a, 1);
			$ord = ord($chr);
			if ($ord > 127) { // This means multibyte! (first byte!)
				if ($ord & 64) { // Since the first byte must have the 7th bit set we check that. Otherwise we might be in the middle of a byte sequence.
					$buf = $chr; // Add first byte
					for ($b = 0; $b < 8; $b++) { // for each byte in multibyte string...
						$ord = $ord << 1; // Shift it left and ...
						if ($ord & 128) { // ... and with 8th bit - if that is set, then there are still bytes in sequence.
							$a++; // Increase pointer...
							$buf .= substr($str, $a, 1); // ... and add the next char.
						} else {
							break;
						}
					}

					$outStr .= '&#' . $this->utf8CharToUnumber($buf, 1) . ';';
				} else {
					$outStr .= chr($this->noCharByteVal);
				} // No char exists (MIDDLE of MB sequence!)
			} else {
				$outStr .= $chr;
			} // ... otherwise it's just ASCII 0-127 and one byte. Transparent
		}

		return $outStr;
	}
190363
public function hasMultiBytes($str)
    {
        if (function_exists('mb_strlen')) {
            return (strlen($str) > mb_strlen($str, $this->CharSet));
        } else { // Assume no multibytes (we can't handle without mbstring functions anyway)
            return false;
        }
    }
649939
public static function setCharset($charset = Base32Characters::RFC3548){
		if(strlen($charset) === 32){
			self::$charset = strtoupper($charset);
		}
		else{
			throw new Base32Exception('Length must be exactly 32');
		}
	}