Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 1.97 KB

portable_filenames_POSIX.md

File metadata and controls

36 lines (27 loc) · 1.97 KB

2022-07-14

Sometimes it's just good to know how to make the most portable types of filenames. Then it's good to know about the POSIX standard, seen below. In this modern day and age you could assume for normal cases that max string length could be 255 chars, but for backwards compatibility stick to 14 as noted below. PS. The max length includes the file extension.

Allowed Chars: A–Z a–z 0–9 . _ - Reserved Chars: / null Max length: 14

Hyphen must not be first character. A command line utility checking for conformance, "pathchk", is part of the IEEE 1003.1 standard and of The Open Group Base Specifications.

Here's some easy to copy code of all allowed characters in the above standard:

List

allowed_chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '.', '_', '-']

String

allowed_chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz._-"

References:

This webpage might be helpful for you: https://regex101.com/