▲ | 0x000xca0xfe 4 days ago | |||||||||||||||||||||||||||||||||||||
> If you stuff random binary data into a string, Go just steams along, as described in this post. > Over the decades I have lost data to tools skipping non-UTF-8 filenames. I should not be blamed for having files that were named before UTF-8 existed. Umm.. why blame Go for that? | ||||||||||||||||||||||||||||||||||||||
▲ | thomashabets2 4 days ago | parent [-] | |||||||||||||||||||||||||||||||||||||
Author here. What I intended to say with this is that ignoring the problem if invalid UTF-8 (could be valid iso8859-1) with no error handling, or other way around, has lost me data in the past. Compare this to Rust, where a path name is of a different type than a mere string. And if you need to treat it like a string and you don't care if it's "a bit wrong" (because it's for being shown to the user), then you can call `.to_string_lossy()`. But it's be more hard to accidentally not handle that case when exact name match does matter. When exactness matters, `.to_str()` returns `Option<&str>`, so the caller is forced to deal with the situation that the file name may not be UTF-8. Being sloppy with file name encodings is how data is lost. Go is sloppy with strings of all kinds, file names included. | ||||||||||||||||||||||||||||||||||||||
|