"All possible characters have a UTF-8 representation so this function
[encode_utf8] cannot fail."
What about non-characters, i.e., byte sequences that are invalid UTF-8?
What I found was that using \N{...} implies a Unicode string. From the
charnames(3) man page (stranged not named "perlcharnames"):
Otherwise, any string that includes a "\N{charname}" or "\N{U+code
point}" will automatically have Unicode rules (see "Byte and
Character Semantics" in perlunicode).
Maybe pack("C") somehow can get to the bytes from a Unicode string?
Sorry I don't have time to experiment more. Must go look at the
first bug reports from the pretest ... --thanks, karl.