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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.