domsson / maxlen

List of string length limits for those who manage memory manually

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

maxlen

This list is an attempt to answer the question "What's the maximum string length for ...?" for as many strings as possible. Note that all numerical values are in bytes (not characters), unless stated otherwise. Also note that many of these numbers can be subject to change; don't hold me responsible if your software breaks.

Linux file paths

  • arbitrarily long

There is PATH_MAX, but it is problematic, as paths might actually be longer than this limit in practice. See, for example, the articles PATH_MAX is tricky and PATH_MAX simply isn't.

Linux file names

  • 255

For most file systems, anyway. See NAME_MAX and the Wikipedia article on file system comparison.

XLogical Font Description

  • 255

Version 1.5 of the XLogical Font Description Conventions PDF says:

The entire font name string must have no more than 255 characters.

IRC messages

  • 512 for the message
  • 8191 for tags

According to RFC-2812, an IRC message (that is, the actual chat message plus meta data, like prefix and parameters) is limited to 512 bytes, which includes the \r\n, leaving 510 bytes for the message. With IRC v3, an IRC message can additionally contain tags, which can use up to 8191 bytes.

Domain name labels (subdomain, domain, TLD)

  • 63 for each label
  • 253 for the entire domain

See this Wikipedia article or RFC-1034.

E-Mail addresses

  • 254

See this detailed Stack Overflow answer for background information, including why the limit is not 320, as often stated.

MIME type

  • 255

That's 127 for the type, 1 for the slash and another 127 for the subtype, according to RFC-4288. Note, however, that the more recent RFC-6838 states that both type and subtype should not exceed 64 characters each.

IP addresses

  • 15 for IPv4
  • 45 for IPv6

See this Stack Overflow question for IPv6; see INET_ADDRSTRLEN and INET6_ADDRSTRLEN for both, IPv4 and IPv6.

YouTube video ID

  • 11

According to the answers on this relevant question on Stack Overflow.

Twitch user and display names

  • 25

According to a reddit post from 2015 and BarryCarlyon, both the user names (nicks) and display names on Twitch can not exceed 25 characters.

Minecraft Server MOTD (message of the day)

  • 59

According to the Gamepedia Minecraft Wiki.

Hex RGB(A) colors

  • 7 for RGB
  • 9 for RGBA

Easily determined: 2 bytes for each color channel, plus 1 byte for the # character.

About

List of string length limits for those who manage memory manually

License:Creative Commons Zero v1.0 Universal


Languages

Language:C 100.0%