Live data from Hacker News

Filenames with Accents (2011)

nedbatchelder.com

1–10 of 19 posts

Re: Filenames with Accents (2011)

#2
You should normalize names on write, on read is very hard to fix. You can have a perfectly valid, denormalized strings representing codepoints with different normalizations.

So if you have four possible normalizations: NFD, NFC, NFKD, NFKC and your string has N ambiguous codepoints, the number of possible strings you need to try is N^4.

Re: Filenames with Accents (2011)

#4
post #2

You should normalize names on write, on read is very hard to fix. You can have a perfectly valid, denormalized strings representing codepoints with different normalizations. So if you have four possible normalizations: NFD, NFC, NFKD, NFKC and your string has N ambiguous codepoints, the number of possible strings you need to try is N^4.

seems like the only way to really achieve that is to bake it into the api for storing/naming files of the respective operating system

Re: Filenames with Accents (2011)

#5

Side note - after all these years I still don't feel comfortable with using special characters (like ą, ż, ź) and spaces in filenames in Windows. DOS times sit deeply in my soul and It just doesn't feel right.

This is amusing but my filesystem has no spaces in it. It's still a pain in the ass from the command line to handle spaces and instead of `-print0` and all that shit I just ban spaces from my filesystem. `-` and `_` are sufficient as spacers.

I know zsh handles auto-complete well but I can `y-a-w` out of my `nvim` `:terminal` a lot easier.

Re: Filenames with Accents (2011)

#6

Side note - after all these years I still don't feel comfortable with using special characters (like ą, ż, ź) and spaces in filenames in Windows. DOS times sit deeply in my soul and It just doesn't feel right.

This is amusing but my filesystem has no spaces in it. It's still a pain in the ass from the command line to handle spaces and instead of `-print0` and all that shit I just ban spaces from my filesystem. `-` and `_` are sufficient as spacers. I know zsh handles auto-complete well but I can `y-a-w` out of my `nvim` `:terminal` a lot easier.

I like this approach. How do you enforce your ban? Is there a mount(8) option for that? Or do you simply avoid these filenames "by hand"? What happens if you untar an archive and it contains filenames with spaces?

Re: Filenames with Accents (2011)

#7
post #6

Earlier quoted context omitted.

This is amusing but my filesystem has no spaces in it. It's still a pain in the ass from the command line to handle spaces and instead of `-print0` and all that shit I just ban spaces from my filesystem. `-` and `_` are sufficient as spacers. I know zsh handles auto-complete well but I can `y-a-w` out of my `nvim` `:terminal` a lot easier.

I like this approach. How do you enforce your ban? Is there a mount(8) option for that? Or do you simply avoid these filenames "by hand"? What happens if you untar an archive and it contains filenames with spaces?

Haha, I do not enforce the ban. You are correct. If I untar'd something I'd be sitting there with a space there and I'd look like a fool. In practice, most of these files are in my `~/Downloads` and I don't really keep them around there very much.

Re: Filenames with Accents (2011)

#8

Side note - after all these years I still don't feel comfortable with using special characters (like ą, ż, ź) and spaces in filenames in Windows. DOS times sit deeply in my soul and It just doesn't feel right.

It hurts readability because l and ł are completely different

Re: Filenames with Accents (2011)

#9
post #4
post #2

You should normalize names on write, on read is very hard to fix. You can have a perfectly valid, denormalized strings representing codepoints with different normalizations. So if you have four possible normalizations: NFD, NFC, NFKD, NFKC and your string has N ambiguous codepoints, the number of possible strings you need to try is N^4.

seems like the only way to really achieve that is to bake it into the api for storing/naming files of the respective operating system

Indeed. The unix world would be a much happier place if the creat system call normalized the strings it receives to replace literal spaces with non-breaking spaces, and similar stuff. Regular users wouldn't notice, and it would simplify tons of shell scripts.

Re: Filenames with Accents (2011)

#10

Side note - after all these years I still don't feel comfortable with using special characters (like ą, ż, ź) and spaces in filenames in Windows. DOS times sit deeply in my soul and It just doesn't feel right.

I've learned to live without file extensions... but I still wince at 4-letter file extensions. I haven't used windows in almost 20 years.
Post reply on HN