Sign in to follow this  
Followers 0
philw

utf-8 without byte order mark

4 posts in this topic

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!

Share this post


Link to post
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.

Share this post


Link to post
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)

Share this post


Link to post
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
Sign in to follow this  
Followers 0