Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> Filenames on Unix can be arbitrary byte sequences, and even on Windows they can be characters that don't exist in the current locale.

In which case(s) it is the responsibility of the thing that wants to print them to make them printable, right?

I guess we're using different definitions of "printable" which makes this a discussion rooted in semantics which isn't very interesting.



> In which case(s) it is the responsibility of the thing that wants to print them to make them printable, right?

Which makes surfacing that responsibility to your application code, as Rust does, better than e.g. silently turning them into empty strings, as some other languages do, no?


i mean in the most abstract sense then yes? but this isn't how rust works in practice. if i try to print(filename) and the program won't compile because filename is `esoteric_string_type&' a` and print expects `abstract trait type SpecificPrintable` or whatever then no this is not a preferable outcome vs. allowing the program to compile and print something that works -- at least in the general case

i mean you can create a file with name `0x01 0x04 0xff 0x0a` but it's not like e.g. `ls` handles this stupidity




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: