OK, that didn't work with BOM-less UTF-8 files.  This (even uglier)
version does, though:


Code:
--------------------
    
        elsif ( $type =~ /html/ ) {
                require HTML::FormatText;
                require File::Slurp;
                my $htmlfh;
                my $encoding;
                $content = File::Slurp::read_file($path);
                $content = Slim::Utils::Unicode::stripBOM($content);
  
                #<meta http-equiv="Content-Type" content="text/html; 
charset=utf-8">
  
                if ( $content =~ /charset=([^"']+)/ ) {
                        $encoding = uc($1);
                }
  
                if ( $encoding ){
                        main::DEBUGLOG && $log->debug("Encoding of $path is 
$encoding ..");
                        if ( open($htmlfh, "<:encoding($encoding)", $path) ){
                                $content = do { local $/; <$htmlfh> }; # read 
all content from file
                                close $htmlfh;
                                $content = HTML::FormatText->format_string(
                                        $content,
                                        leftmargin => 0,
                                );
                        }
                } else {
                        $content = HTML::FormatText->format_file(
                                $path,
                                leftmargin => 0,
                        );
                }
        }
  
  
--------------------


------------------------------------------------------------------------
gharris999's Profile: http://forums.slimdevices.com/member.php?userid=115
View this thread: http://forums.slimdevices.com/showthread.php?t=99537

_______________________________________________
plugins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/plugins

Reply via email to