1

I'm doing a tutorial on learning lua: https://www.lua.org/pil/1.html

I'm trying to open a simple file called hello.lua that I created with Textedit, located in the folder "luaProjects". The file contains the following line:

print("Hello World")

I get an error however, when I try to run the hello world script like this:

luaProjects username$ lua hello.lua
lua: hello.lua:1: unexpected symbol near char(226)

I think that lua is installed correctly:

User-MacBook-Air:~ username$ lua -v
Lua 5.2.4  Copyright (C) 1994-2015 Lua.org, PUC-Rio

And I think that I have set the folder and file up correctly:

User-MacBook-Air:luaProjects username$ tree
.
└── hello.lua

0 directories, 1 file

Q: Does anyone know how to fix this?

2 Answers 2

3

It could be that your double quotation marks are not ascii, but unicode left/right double quotation marks. Those start with 0xe2, exactly yours 226.

Try some simpler editor, or explicitly save file as ascii.

0

Avoid saving lua code files as unicode and convert your existing files via:

iconv -f utf-8 -t ascii YOURFILE

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.