Re: character constants

  • From: Duncan Cross <duncan.cross@xxxxxxxxx>
  • To: luajit@xxxxxxxxxxxxx
  • Date: Thu, 17 May 2012 10:19:53 +0100

On Thu, May 17, 2012 at 1:41 AM, William Adams <william_a_adams@xxxxxxx> wrote:
> In lua, there are only strings right?  And the single quotes are just
> dummies for double quotes, so 'a' ~= single byte representation of the ascii
> character a.

Yes.

> Before I go ahead and create the constants for all the ascii characters, is
> there a better way of doing this, or some magical character I can put in
> front of a string literal to get the constant for the first character
> without having to make a function call?

No, I'm afraid there is nothing like that. string.byte() is all you have.

(This seems like a general Lua question, rather than LuaJIT related.
Are you asking here instead of the main Lua list because you think
there might be something specific to LuaJIT involved?)

-Duncan

Other related posts: