From: Steve Hancock Date: Sun, 22 Mar 2020 01:55:20 +0000 (-0700) Subject: remove BOM if any X-Git-Tag: 20200619~126 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=67c48a2e2baab5fd5e3665e35c3e3a8caf6e29eb;p=perltidy.git remove BOM if any --- diff --git a/lib/Perl/Tidy.pm b/lib/Perl/Tidy.pm index d9433dff..9cc42f56 100644 --- a/lib/Perl/Tidy.pm +++ b/lib/Perl/Tidy.pm @@ -992,6 +992,11 @@ EOM # we must not treat it as encoded data. my $is_encoded_data = $encoding_in ? 'utf8' : ""; + # Delete any Byte Order Mark (BOM), which can cause trouble + if ($is_encoded_data) { + $buf =~ s/^\x{FEFF}//; + } + # MD5 sum of input file is evaluated before any prefilter if ( $rOpts->{'assert-tidy'} || $rOpts->{'assert-untidy'} ) { $digest_input = $md5_hex->($buf);