use strict; use warnings; use Devel::Peek; use Encode; use utf8; my $string = "123\x{444}\x{444}\x{444}\x{444}"; binmode STDOUT, ":utf8"; Dump $string; print "UTF IS ON\n" if utf8::is_utf8($string); print "LENGTH DIFFERS\n" if length($string) != bytes::length($string); open my $f, ">", "test1"; binmode $f; syswrite $f, $string or die; print "ALL OK\n"; __END__ SV = PV(0x258cb78) at 0x25b7bb0 REFCNT = 1 FLAGS = (PADMY,POK,pPOK,UTF8) PV = 0x25aad60 "123\321\204\321\204\321\204\321\204"\0 [UTF8 "123\x{444}\x{444}\x{444}\x{444}"] CUR = 11 LEN = 16 UTF IS ON LENGTH DIFFERS Wide character in syswrite at poc1.pl line 16.