Daily Shaarli

All links of one day in a single page.

November 13, 2015

osx - Unicode encoding for filesystem in Mac OS X not correct in Python? - Stack Overflow

Point très précis d'encodage de nom de fichier en UTF-8 spécial pour Mac OS X.
cf aussi : https://docs.python.org/2/library/unicodedata.html

Il faut retenir ceci pour les noms de fichiers uniquement :

  • UTF-8 : MAC -> LINUX : unicodedata.normalize('NFC', unicode(filename, 'utf-8')).encode('utf-8')
  • UTF-8 : LINUX -> MAC : unicodedata.normalize('NFD', unicode(filename, 'utf-8')).encode('utf-8')

cf aussi ici : https://blog.hbis.fr/2010/08/30/macox-utf8_filenames_normalization/

EDIT :
voir aussi ici pour RSYNC :
http://serverfault.com/questions/397420/converting-utf-8-nfd-filenames-to-utf-8-nfc-in-either-rsync-or-afpd