readpipe returns perl a string of unspecified bytes. We know that this string is encoded in UTF-8 encoding, but you did not tell Perl.
The I / O level on your output descriptor takes this line, assuming these are Unicode code codes and transcodes them as UTF-8 bytes.
The reason that the IO-Latin-1 level works correctly is because it writes every non-encoded byte unchanged, because the 1st 256-bit Unicode code works well with Latin-1.
The right thing to do is to decode byte string returned by readpipe to the line of code before feeding it to the IO layer. The use open ':utf8' statement, as Borodin mentioned, should be a viable solution since readpipe specifically mentioned on the open page .
source share