Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^3: perltidy and UTF-8 BOM

by haukex (Chancellor)
on May 21, 2018 at 14:17 UTC ( #1214986=note: print w/replies, xml ) Need Help??


in reply to Re^2: perltidy and UTF-8 BOM
in thread perltidy and UTF-8 BOM

The Byte order mark is the Unicode character U+FEFF, and depending on the encoding it is encoded as different bytes - see "Byte order marks by encoding" on the same Wikipedia page. Because I've changed STDIN and STDOUT to be UTF-8 with the command-line switch -CS, I can use the Unicode representation and don't need to look at the bytes (although I could do that too, but I figured since everything is UTF-8 already anyway...).

$ perl -wMstrict -CSD -e 'print "\x{FEFF}"' | hexdump -C 00000000 ef bb bf |...| $ perl -wMstrict -e 'binmode STDOUT, ":raw:encoding(UTF-8)"; print + "\x{FEFF}"' | hexdump -C 00000000 ef bb bf |...| $ perl -wMstrict -e 'binmode STDOUT, ":raw:encoding(UTF-16-LE)"; print + "\x{FEFF}"' | hexdump -C 00000000 ff fe |..| $ perl -wMstrict -e 'binmode STDOUT, ":raw:encoding(UTF-16-BE)"; print + "\x{FEFF}"' | hexdump -C 00000000 fe ff |..| $ perl -wMstrict -e 'binmode STDOUT, ":raw:encoding(UTF-32-LE)"; print + "\x{FEFF}"' | hexdump -C 00000000 ff fe 00 00 |....| $ perl -wMstrict -e 'binmode STDOUT, ":raw:encoding(UTF-32-BE)"; print + "\x{FEFF}"' | hexdump -C 00000000 00 00 fe ff |....|

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1214986]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2019-12-08 08:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?