diff --git a/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp b/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp index be53250526..bb0bf2ce13 100644 --- a/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp +++ b/cocos/scripting/lua-bindings/manual/CCLuaStack.cpp @@ -862,6 +862,14 @@ int LuaStack::luaLoadBuffer(lua_State *L, const char *chunk, int chunkSize, cons } else { + // UTF-8 BOM? skip + if (static_cast(chunk[0]) == 0xEF && + static_cast(chunk[1]) == 0xBB && + static_cast(chunk[2]) == 0xBF) + { + chunk += 3; + chunkSize -= 3; + } r = luaL_loadbuffer(L, chunk, chunkSize, chunkName); }