Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: perltidy and UTF-8 BOM

by AnomalousMonk (Bishop)
on May 21, 2018 at 13:57 UTC ( #1214983=note: print w/replies, xml ) Need Help??


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

... s/\A\x{FEFF}// ... print "\x{FEFF}" ...

Again, a total UTF-8 n00b (or maybe nob) here, but isn't the UTF-8 BOM  "\xEF\xBB\xBF" (239 187 191) (see this and the perltidy complaint cited in the OP)? (And  \x{FEFF} works out to decimal 65279.)


Give a man a fish:  <%-{-{-{-<

Replies are listed 'Best First'.
Re^3: perltidy and UTF-8 BOM
by haukex (Chancellor) on May 21, 2018 at 14:17 UTC

    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://1214983]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2019-11-20 01:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (96 votes). Check out past polls.

    Notices?