Plain text library stacks - BOM needed

Mark Waddingham mark at livecode.com
Fri May 1 03:19:56 EDT 2015


> I’ve found that when LiveCode saves the stack script file, it adds a
> Byte Order Mark (BOM) to denote the file is UTF-8 encoded. If the BOM
> is not present when you start using such a library stack, the engine
> will treat it as being natively encoding. I have found that to be true
> with both the IDE and Server engines. So if you want to create script
> only stacks in an external editor make sure that the editor adds a BOM
> when you save the file.

I do wonder, with hindsight, whether this was a mistake and the engine 
should just assume UTF-8 encoding (unless it encounters a UTF-16 BOM) of 
script-only text files. Given this is the default of most text editors 
these days, and the encoding the engine uses when saving script-only's 
itself it might simplify things slightly.

> If you write scripts to run with LiveCode Server that start with a
> shebang line, be aware that they do not work if there is a BOM
> present.

Yes - the shell's processing of #! on Linux (and other platforms) 
requires #! to be the first two chars of the file.

This is why we added the ability to specify the encoding of server 
script files by adding a comment on the second line of the form:
   # encoding=utf-8

-- 
Mark Waddingham ~ mark at livecode.com ~ http://www.livecode.com/
LiveCode: Everyone can create apps




More information about the use-livecode mailing list