3 ms·
I use this transform chain for asciifying filenames (ridiculous as it is, in 2019 we still can't sync unicode filenames between different OSs): uconv -x ':
by aaaaaaaaaab 8y ago
I use this transform chain for asciifying filenames (ridiculous as it is, in 2019 we still can't sync unicode filenames between different OSs):
uconv -x ':: Any-Latin; :: Latin-ASCII; [:^ASCII:] > \_'
Explanation:
Any-Latin
Transliterates from non-latin scripts to latin script (e.g. "γραφὴν" --> "graphḕn").
Latin-ASCII
Tries to asciify characters as much as possible by discarding accents, splitting ligatures, replacing Unicode quotes with regular quotes, © --> (C), etc.
[:^ASCII:] > \_
Replaces any remaining non-ASCII characters with an underscore.
- gumby 8y agoWhy not transform them into utf-8, say with iconv?
- aaaaaaaaaab 8y agoHow would that help when e.g. copying files from a Linux server to macOS via Samba? Mind you, the filenames can contain both NFC, NFD or the mixture of the two.
- gumby 8y agoWell you're talking about filenames, right? Not the content? My understanding (which could be quite wrong) is that Windows refers NFC and MacOS prefers NFD (as do I but I understand the NFC desire) but that the filesystems themselves do not do normalization. In which case, modulo delimiters, every filename in one is legit in the other. My suggestion of utf8 was to make a byte-order and code point width invariant form that should be completely reversible. But if that doesn't work, never mind.
- umlautae 8y agoDo you care to chime in with your use case for our patch discussion? I am trying to argue for the translit to be most useful for asciifying filenames among the others. Another actual user will help to make the case. https://sourceware.org/ml/libc-locales/2019-q1/msg00014.html https://sourceware.org/ml/libc-locales/2019-q1/msg00014.html
- jwilk 8y agoWhat does "::" mean?
- aaaaaaaaaab 8y agoIt’s part of uconv’s transform rule syntax: >Each transform rule consists of two colons followed by a transform name. http://userguide.icu-project.org/transforms/general#TOC-Compound-IDs http://userguide.icu-project.org/transforms/general#TOC-Comp...