lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Sep 05, 2011 at 12:25:22AM +0200, Josh Simmons wrote:
> On Mon, Sep 5, 2011 at 2:31 AM, Dirk Laurie <dpl@sun.ac.za> wrote:
> > Since a C "char" is not a Lua "character", consider using
> > "byte" instead of "character" at the following places:
> A C char _is_ a Lua character. There's no encoding forced on either
> side and there's no concept of a byte in C.

My point has to do with the way 'byte' and 'character' are used in the
Lua 5.2 manual.  

Already in the 5.1 manual, an essential distinction between the terms
is made.

    The length of a string is its number of bytes (that is, the usual 
    meaning of string length when each character is one byte). 

    The string library assumes one-byte character encodings.

In the 5.2 manual, the word 'character' appears in the definition of 
a string.

5.1  _String_ represents arrays of characters.  Lua is 8-bit clean: strings 
    can contain any 8-bit character, including embedded zeros ('\0').
5.2  _String_ represents immutable sequences of bytes. Lua is 8-bit clean: 
    strings can contain any 8-bit value, including embedded zeros ('\0').  

The purpose of the original post was to point out other places in the 
manual where this particular change of terminology may be desirable.

I apologise for the dilution of this point by motivating it in a way
that offers scope for digression.

Dirk