Created
April 30, 2023 18:24
-
-
Save mansourmoufid/b26406d3de0d8bd86fc769ca8ee769d4 to your computer and use it in GitHub Desktop.
macOS 13.3.1 can't open files with names in Unicode normal form C
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
import os | |
import unicodedata | |
def dump(s): | |
for character in s: | |
print('\t{}\t{}\t{}'.format( | |
character, | |
' '.join([hex(x) for x in character.encode('utf-8')]), | |
unicodedata.name(character), | |
)) | |
filename = 'français.txt' | |
filename = unicodedata.normalize('NFD', filename) # Comment out this line | |
dump(filename) | |
try: | |
os.remove(filename) | |
except FileNotFoundError: | |
pass | |
with open(filename, 'wt') as f: | |
print('Bonjour!', file=f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment