Skip to content

Instantly share code, notes, and snippets.

@mansourmoufid
Created April 30, 2023 18:24
Show Gist options
  • Save mansourmoufid/b26406d3de0d8bd86fc769ca8ee769d4 to your computer and use it in GitHub Desktop.
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
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