Jump to content

utf-8 without byte order mark


philw
 Share

Recommended Posts

Is there any way to save files as utf-8, but without the byte order mark? The program I'm working on creates html files, and the w3c validator warns that including the byte order mark can cause problems when these are viewed in certain browsers.

Thanks!

Link to comment
Share on other sites

I agree that the validation tool is far from perfect! It's just that, if the byte order mark is not actually necessary in Utf-8, should it be there? Does it do anything? Ok, browsers (and other applications) that get confused by the BOM are probably dinosaurs, but surely there's no point in including something that might cause issues, however unlikely this may be.

Link to comment
Share on other sites

Specifically not including BOM is like adding support for Mosaic, Netscape and IE4 browsers.

You can read more about the subject here and here:

http://en.wikipedia.org/wiki/UTF-8#Byte-order_mark

http://en.wikipedia.org/wiki/Byte-order_mark

To answer your original question, though, AutoIt FileOpen and FileWrite never write a BOM unless you specifically tell it to. If you have a string that already contains a byte order mark you can remove it like so:

$s = StringToBinary("This is my string with a BOM.")

ConsoleWrite("String length with BOM: " & BinaryLen($s) & @CRLF)

$s = BinaryMid($s, 3, BinaryLen($s)-3)

ConsoleWrite("String length without BOM: " & BinaryLen($s) & @CRLF)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...