Maximum string length

@param   string
@param   int
@return  bool
18353
public function _validation_max_length($val, $length)
	{
		return $this->_empty($val) || \Str::length($val) <= $length;
	}
419886
private static int getMaxLength( String[] values )
    {
        int result = 0;
        
        for ( int i = 0, curr = 0; i < values.length; i++ )
        {
            if ( ( curr = values[i].length() ) > result )
            {
                result = curr;
            }
        }
        return result;
    }
861888
public function maxLength(int $length) : Element
    {
        $this->attributes['maxlength'] = (int)$length;
        return $this->addTest('maxlength', function($value) use ($length) {
            return mb_strlen(trim($value), 'UTF-8') <= (int)$length;
        });
    }
1161430
public function write($string)
    {
        $this->content = Text::insert($this->content, $this->position, $string);
        $len = strlen($string);
        $this->position += $len;
        return $len;
    }
504514
private static int getMaxStringLength(String[] names) {
		int size = 0;
		for(String s : names) {
			if(s.length()>size) {
				size = s.length();
			}
		}
		return size;
	}
1248467
public function writeString($string)
    {
        // $maxLen = 2^16 -1 = max val of unsigned short integer.
        $maxLen = 65535;
        $len = strlen($string);

        if ($len > $maxLen) {
            $len = $maxLen;
            $string = substr($string, 0, $maxLen);
        }

        try {
            $this->getStream()->write(pack('S', $len) . $string);
        } catch (StreamException $e) {
            $this->handleStreamException($e, BinaryStreamAccessException::STRING, false);
        }
    }
156695
public static function sizeStringToBytes($string)
    {
        // '-1' happens more often than not to denote an "unlimited" or "not defined" size, so let's reduce some
        // overhead of doing the conversion if possible.
        if ('-1' === $string) {
            return -1;
        }

        $max = strtolower(ltrim($string, '+'));

        if (0 === strpos($max, '0x')) {
            $max = intval($max, 16);
        } elseif (0 === strpos($max, '0')) {
            $max = intval($max, 8);
        } else {
            $max = intval($max);
        }

        switch (substr($string, -1)) {
            case 't': $max *= 1024;
            case 'g': $max *= 1024;
            case 'm': $max *= 1024;
            case 'k': $max *= 1024;
        }

        return $max;
    }
165183
private function maxLength()
	{
		$max = mb_strlen($this->value);
		if (!$ret = $max <= $this->options->max) {
			$this->error(1);
		}

		return $ret;
	}
1133300
function maxlength (val, max) {
  if (typeof val === 'string') {
    return isInteger(max, 10) && val.length <= parseInt(max, 10)
  } else if (Array.isArray(val)) {
    return val.length <= parseInt(max, 10)
  } else {
    return false
  }
}
134477
public static function maxLength($value, $param)
    {
        $length = is_array($value) ? count($value) : mb_strlen($value);

        return $length <= $param;
    }
882513
public static function isValid($string)
    {
        if (is_int($string) || is_float($string)) {
            return true;
        }

        json_decode($string);

        return json_last_error() === JSON_ERROR_NONE;
    }
35550
public function max($str, $length)
    {
        return $this->notempty($str) && strlen(trim($str)) <= $length;
    }
1191507
public function setMaxLength($maxLength)
    {
        if ($this->type !== self::TYPE_STRING) {
            throw new \Exception('maxLength can only be set on type "string"');
        }

        $this->maxLength = (int) $maxLength;
    }
88675
public static function isMultibyte($string)
    {
        $length = strlen($string);

        for ($i = 0; $i < $length; $i++) {
            $value = ord($string[$i]);
            if ($value > 128) {
                return true;
            }
        }

        return false;
    }
434033
public function getStringValue($key, $maxlength = null)
    {
        $value = $this->get($key);
        if ($value === null) {
            return null;
        }
        return ($maxlength === null) ? $value : substr($value, 0, $maxlength);
    }
1270482
public static function truncate(string $string, int $maxLength, string $indicator = '...'): string
    {
        if (mb_strlen($string) > $maxLength) {
            $string = mb_substr($string, 0, $maxLength - mb_strlen($indicator)) . $indicator;
        }

        return $string;
    }
782980
public function read($length)
    {
        if ($this->offset == $this->array_size) {
            return false;
        }

        // Don't use array slice
        $arrays = [];
        $end = $length + $this->offset;
        for ($i = $this->offset; $i < $end; ++$i) {
            if (!isset($this->array[$i])) {
                break;
            }
            $arrays[] = $this->array[$i];
        }
        $this->offset += $i - $this->offset; // Limit function calls
        $chars = false;
        foreach ($arrays as $array) {
            $chars .= implode('', array_map('chr', $array));
        }

        return $chars;
    }