in reply to IO::Compress::Gzip and unicode

The easy approach would be to use Encode::encode to convert your string to octets before writing it to the file:

my $unicode_string = "Smiley Face: \x{263A}\n"; my $bytes = encode('UTF-8', $unicode_string); binmode $fh, ':raw'; print {$fh} $bytes;

But I think that the binmode ':utf8' already should do that. Maybe there is a difference between :utf8 and :encoding(UTF-8), so maybe try:

binmode $fh, ':encoding(UTF-8)';

in your code instead.

But as you already looked at the documentation of IO::Compress::Gzip and it doesn't have a proper binmode implementation, you will need to do that yourself I fear.