Last active
March 4, 2021 22:27
-
-
Save andreubotella/11b9c521cb52872f669c07846a9903da to your computer and use it in GitHub Desktop.
Writer of files with weird filenames
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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