3 ms·
Filenames aren't text, they're bytes. You shouldn't decode them except if you need to for display (and in that case, you should be prepared to handle filenames
by ddevault 8y ago
Filenames aren't text, they're bytes. You shouldn't decode them except if you need to for display (and in that case, you should be prepared to handle filenames which cannot be decoded as text). You should decode data into it's canonical representation as early as possible and encode it as late as possible, but the canonical representation of a filename is not text.
- bartwe 8y agoFilenames are text if you ever want to let a user interact with them by name.
- Sir_Cmpwn 8y agoI addressed this in my original comment.
- ProblemFactory 8y agoThe two conditions * OS treats filenames as bytes and allows arbitrary byte strings, * Users want to edit filenames as text are in conflict and you can't solve it without forcing some encoding or giving them a byte editor. The solution "filenames are bytes but we'll treat it as ASCII because 0x32-0x7E should be enough for anybody" is not acceptable for möst of thé wõrld.