If encoding and decoding '' did reproduce '', you could then complain that encoding and decoding undef would not reproduce undef (but '' instead)...
But isn't the 'standard' (or at any rate the typical) Perl way to handle undef in numeric and string contexts to coerce it to 0 or the empty string, respectively, and issue warnings as appropriate? Conversely, is there any other numeric or string context in which the empty string is coerced to undef?
Reason is that uuencoding-wise, there is no way to distinguish an empty string from an undefined value...
Are you saying by this that the UU-encoding standard specifies no way to encode an empty string, i.e., that an empty string is, literally, 'undefined' in the standard? If this is the case, I would expect undef to be produced by the encoding step as well as by decoding.
Perhaps the basic problem here is that I am simply unfamiliar with and do not understand the UU-encoding process.
| [reply] [d/l] [select] |
Are you saying by this that the UU-encoding standard specifies no
way to encode an empty string, i.e., that an empty string is,
literally, 'undefined' in the standard?
Not quite. All I was trying to say is that while Perl variables
internally have meta information to tell apart undef from empty, the
uuencoding format doesn't have any such provision. I.e. an empty
string encodes to an empty string (nothing, zero bytes), and as it
isn't really specified how to encode an undefined value, the nearest
approximation would be to also encode it as nothing (zero
encoded chars/bytes).
Now, when you're faced with having to decode that nothing, you
cannot tell whether it has been generated by an empty string, or undef.
So you just have to make some choice... and it's kind of arbitrary
whether you consider decoding nothing into undef or the empty string as
more appropriate.
| [reply] |