> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Gene Falck
> Sent: 20 February 2005 04:26

> OK, I understand about the BOM but this still leaves me 
> wondering how to save properly. I usually code using Notepad 
> which offers, from the Save As... menu choice, the Encoding options:
> 
> ANSI
> Unicode
> Unicode big endian
> UTF-8
> 
> but no UTF-6 BOM. How can I be sure I am saving in the right way?

I think you need to use a different editor, or (as I do) strip the BOM off
before publishing.

You may also find the following article useful. It explains the BOM and the
effects it can sometimes have on pages when present:
http://www.w3.org/International/questions/qa-utf8-bom
"FAQ: Unexpected characters or blank lines"


Here is the code of a Perl script I use to strip the BOM.  It's just a quick
hack, nothing beautiful, but it may help you or others when you cannot avoid
saving with a BOM.  (I call it by invoking a batch file in my Windows
directory: removebom <filename>.)

===================
# program to remove a leading UTF-8 BOM from a file
# works both STDIN -> STDOUT and on the spot (with filename as argument)

if ($#ARGV > 0) {
    print STDERR "Too many arguments!\n";
    exit;
}

my @file;   # file content
my $lineno = 0;

my $filename = @ARGV[0];
if ($filename) {
        open( BOMFILE, $filename ) || die "Could not open source file for
reading.";
        while (<BOMFILE>) {
                if ($lineno++ == 0) {
                        if ( index( $_, '?' ) == 0 ) {
                                s/^\xEF\xBB\xBF//;
                                print "BOM found and removed.\n";
                                }
                        else { print "No BOM found.\n"; }
                                }
                        push @file, $_ ;
                }
        close (BOMFILE)  || die "Can't close source file after reading.";

        open (NOBOMFILE, ">$filename") || die "Could not open source file
for writing.";
        foreach $line (@file) {
                print NOBOMFILE $line;
                }
        close (NOBOMFILE)  || die "Can't close source file after writing.";
        }
else {  # STDIN -> STDOUT
        while (<>) {
                        if (!$lineno++) {
                                s/^\xEF\xBB\xBF//;
                                }
                        push @file, $_ ;
                }
        foreach $line (@file) {
                        print $line;
                }
        }
===================

HTH
RI

============
Richard Ishida
W3C

contact info:
http://www.w3.org/People/Ishida/ 

W3C Internationalization:
http://www.w3.org/International/ 

Publication blog:
http://people.w3.org/rishida/blog/
 





******************************************************
The discussion list for  http://webstandardsgroup.org/

 See http://webstandardsgroup.org/mail/guidelines.cfm
 for some hints on posting to the list & getting help
******************************************************

Reply via email to