Skip to content

Instantly share code, notes, and snippets.

@andreubotella
Last active March 4, 2021 22:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andreubotella/11b9c521cb52872f669c07846a9903da to your computer and use it in GitHub Desktop.
Save andreubotella/11b9c521cb52872f669c07846a9903da to your computer and use it in GitHub Desktop.
Writer of files with weird filenames
#!/usr/bin/env python3
# Replace this
BASE_PATH = "/home/abotella/filenames_test/".encode("utf-8")
FILENAMES = [
# Basic UTF-8 test (useless on its own, meant to check that multiple files
# work together)
"ûtf-∞".encode("utf-8"),
# UTF-8 starting with BOM
"\uFEFF_utf8_with_bom".encode("utf-8"),
# Latin-1 ("uávëwîxøyùz")
b"u\xE1v\xEBw\xEEx\xF8y\xF9z"
]
FILE_CONTENTS = "Nothing to see here, move along.\n"
for filename in FILENAMES:
with open(BASE_PATH + filename, encoding="utf-8", mode="w") as file:
file.write(FILE_CONTENTS)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment