I have file /tmp/xxx
with next content:
00000000 D0 BA D0 B8 │ D1 80 D0 B8 │ D0 BB D0 B8 │ D0 BA к и р и л и к
When I read content of file and print it I get the error:
Wide character in print at ...
The source is:
use utf8;
open my $fh, '<:encoding(UTF-8)', '/tmp/xxx';
print scalar <$fh>
The output from print is:
кирилик
$ perl -e 'print "\x {194} "' Wide character in print at -e line 1. Ɣ You can solve this using several different methods. The first way to solve this is through command line flags. Perl supports the -C option that allows control over the default character set. ( Documentation) There are several options to choose from: -CSDA is the most complete.
How to Troubleshoot a Printer With Weird Characters 1 Cancel the Print Job. Sometimes, a print job simply gets stuck upon sending. ... 2 Re-Send the Print Job. Once the strange printing has stopped and power is restored to the printer, try printing the page again. 3 Re-Install Latest Printer Drivers. ... 4 Replace USB Cable. ...
Once the strange printing has stopped and power is restored to the printer, try printing the page again. This is important, as it will tell you whether or not the issue was a temporary fault or is a persistent problem. If the same file prints again as garbage, cancel the print job as before and send a different print job.
It can look like something out of a horror movie: after sending a print job, your printer begins spewing pages and pages of weird characters. With the heavy demands business place on the average printer, you’re bound to experience this at one time or another.
You're printing to STDOUT which isn't expecting UTF8. Add
binmode(STDOUT, "encoding(UTF-8)");
to change that on the already opened handle.
The use utf8
means Perl expects your source code to be UTF-8.
The open
pragma can change the encoding of the standard filehandles:
use open qw( :std :encoding(UTF-8) );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With