luabindings: Add script with utf-8 bom support.

This commit is contained in:
halx99 2016-06-21 14:31:25 +08:00 committed by GitHub
parent dd75d37b9d
commit f41130bafe
1 changed files with 8 additions and 0 deletions

View File

@ -862,6 +862,14 @@ int LuaStack::luaLoadBuffer(lua_State *L, const char *chunk, int chunkSize, cons
}
else
{
// UTF-8 BOM? skip
if (static_cast<unsigned char>(chunk[0]) == 0xEF &&
static_cast<unsigned char>(chunk[1]) == 0xBB &&
static_cast<unsigned char>(chunk[2]) == 0xBF)
{
chunk += 3;
chunkSize -= 3;
}
r = luaL_loadbuffer(L, chunk, chunkSize, chunkName);
}