Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get rid of `Wide character in print at`?

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:

кирилик  
like image 311
Eugen Konkov Avatar asked Dec 22 '17 11:12

Eugen Konkov


People also ask

How to print wide character in print at-E Line 1?

$ 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?

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. ...

What should I do if my printer is printing Strange Pages?

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.

Why is my printer spewing pages and pages of characters?

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.


2 Answers

You're printing to STDOUT which isn't expecting UTF8. Add

binmode(STDOUT, "encoding(UTF-8)");

to change that on the already opened handle.

like image 134
janh Avatar answered Sep 18 '22 00:09

janh


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) );
like image 25
brian d foy Avatar answered Sep 21 '22 00:09

brian d foy