open(my $fh, '>:encoding(UTF-8)', ...) or die; print($fh $text);