Reputation: 33
More specifically the full error is
../../Scripts/LuaTest.lua:1: unexpected symbol near 'ï'
I have checked the LuaTest.lua
file with different editors to include Notepad++ and can not find any extra/hidden characters. I'm at a loss to what could be causing this.
Side note, I'm following this guide: Godpatterns: Scripting with Lua in C#
Here is the main code block:
class Program
{
static void Main(string[] args)
{
Lua lua = new Lua();
Program program = new Program();
// register our C# functions
lua.RegisterFunction("DanSays", program, program.GetType().GetMethod("DanSays"));
lua.RegisterFunction("ThorSays", program, program.GetType().GetMethod("ThorSays"));
lua.DoFile("../../Scripts/LuaTest.lua");
Console.ReadLine();
}
public void DanSays(string s)
{
Console.WriteLine("Dan Says > " + s);
}
public void ThorSays(string s)
{
Console.WriteLine("Thor says > " + s);
}
}
Additionally, here is LuaTest.lua
DanSays("Hey, Thor!");
ThorSays("Hi Dan! You know Thursdays . . . ");
DanSays("*sigh* yeah, Thor, I know Thursdays.");
ThorSays("Named after me you know!");
DanSays("Yeah, I know.");
Upvotes: 3
Views: 7583
Reputation: 993941
This is likely caused by a Byte Order Mark that is placed at the start of Unicode text files by some text editors. The bytes of the BOM include 0xEF, which is the ISO 8859-1 character code for ï (latin lowercase i with umlaut).
So your guess is correct, there are hidden characters in there. Configure your text editor to not use a BOM when writing text files.
Upvotes: 5