File tree Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Expand file tree Collapse file tree 1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -498,6 +498,17 @@ sub _parse_version_expression {
498498sub _handle_bom {
499499 my ($self , $fh , $filename ) = @_ ;
500500
501+ my $UTF8_BOM ;
502+ if ( " $] " >= 5.008 ) {
503+
504+ # Works on EBCDIC too
505+ $UTF8_BOM = " \x{FEFF} " ;
506+ utf8::encode($UTF8_BOM );
507+ }
508+ else {
509+ $UTF8_BOM = " \x{EF}\x{BB}\x{BF} " ;
510+ }
511+
501512 my $pos = tell $fh ;
502513 return unless defined $pos ;
503514
@@ -512,10 +523,10 @@ sub _handle_bom {
512523 elsif ( $buf eq " \x{FF}\x{FE} " ) {
513524 $encoding = ' UTF-16LE' ;
514525 }
515- elsif ( $buf eq " \x{EF}\x{BB} " ) {
516- $buf = ' ' ;
526+ elsif ( $buf eq substr ( $UTF8_BOM , 0, 2) ) {
527+ $buf = ' ' x ( length ( $UTF8_BOM ) - 2) ;
517528 $count = read $fh , $buf , length $buf ;
518- if ( defined $count and $count >= 1 and $buf eq " \x{BF} " ) {
529+ if ( defined $count and $count >= 1 and $buf eq substr ( $UTF8_BOM , 2) ) {
519530 $encoding = ' UTF-8' ;
520531 }
521532 }
You can’t perform that action at this time.
0 commit comments