[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: String represents arrays of characters.
- From: Dirk Laurie <dpl@...>
- Date: Tue, 14 Dec 2010 10:21:55 +0200
On Tue, Dec 14, 2010 at 09:51:25AM +0200, Tony Finch wrote:
> The problem with treating a string as an array of characters is that
> characters do not have a uniform size. It is more accurate to treat
> Lua strings as arrays of bytes.
You are right.
According to the Lua reference manual:
"Lua is 8-bit clean: strings can contain any 8-bit value,
including embedded zeros ('\0')."
Lua 5.2.0 (alpha) Copyright (C) 1994-2010 Lua.org, PUC-Rio
> a="Curaçao"; return #a
8
Actually at this stage predicting the result of any string function
except byte and char applied to a Unicode string is for me like
solving a chess problem. E.g.
> s='mêên'; return s:match('ê*')
Don't run to your terminal immediately: figure it out!
Dirk
PS If it does not involve patterns, it is like solving an easy
chess problem!