If you're dealing with lengths, you can get input data in meters, centimeters, millimeters, inches, feet, etc.
If the input data is human heights, would you automatically assume meters even if the input data is "183"?
If the input data is the weight of humans, would you always assume grams, even if the input data is "75"?
It depends on the circumstances. It might be the least bad thing to do. Or not.
But that wasn't my point. I replied to this:
> I can assume the length of a meter or the weight of a gram
Sure, the length of a meter and the "weight" of a gram are both standardized. (To be very picky, "gram" is a mass, not a weight. The actual weight depends on the "g" constant, which on average is 9.81 m/s^2 on earth, but can vary about 0.5%.)
So if you know the input is in meters, you don't need to do any further processing.
But dealing with input text files with an unknown encoding is like dealing with input lengths with an unknown unit.
So while UTF-8 itself might be standardized, it is not the same as all input text files always being in UTF-8.
You can choose to say that all input text files must be in valid UTF-8, or the program refuses to load them. Or you can use silent heuristics. Or something inbetween.
It is not.
https://en.wikipedia.org/wiki/Mars_Climate_Orbiter#Cause_of_...
Write all software like NASA needs to do for spacecraft?
Let me know when anyone has developed a web browser to those standards.
More to the point, what situation can you think of where guessing measurement units is a good idea? In a CNC machine? Maps program? Somewhere else? You seem to have omitted the actual counterargument part from your counterargument, while adding a hearty dash of misplaced outrage.
(yeah, my only grip with SI, but it's a frustrating one.)
(Other than pure ASCII, of course. But "decoding" ASCII text as UTF-8 is safe anyway, so that hardly matters.)
The only way you'd successfully decode Shift-JIS as UTF-8 is if it essentially is just latin-alphabet text (though the yen symbol would incorrectly display as a '\'). If it includes any non-trival amount of Japanese in it, it'll fail to decode as UTF-8.
As for whether or not you can then (after it fails to decode as UTF-8) use statistical analysis to reliably figure out that it's in fact Shift-JIS, and not something else, I can't speak to that.
[0] https://en.wikipedia.org/wiki/Shift_JIS#Shift_JIS_byte_map
Very few developers I’ve met know could make a distinction. They’d see a few off characters and think it’s some one-off bug but it’s because they’re both assuming an encoding.
Even if you said you’d pay them one billion dollars to fix it, they’d absolutely be unable to.
Please pay up front.
Unless you want it fixed immediately, then a million dollars should motivate almost any developer to spend a month learning, a month doing, and a few years on vacation. A billion is incomprehensible.
-
You just won't always be right.