Class LuaString

All Implemented Interfaces:
com.esotericsoftware.kryo.KryoSerializable

public class LuaString extends LuaValue implements com.esotericsoftware.kryo.KryoSerializable
Subclass of LuaValue for representing lua strings.

Because lua string values are more nearly sequences of bytes than sequences of characters or unicode code points, the LuaString implementation holds the string value in an internal byte array.

LuaString values are not considered mutable once constructed, so multiple LuaString values can chare a single byte array.

Currently LuaStrings are pooled via a centrally managed weak table. To ensure that as many string values as possible take advantage of this, Constructors are not exposed directly. As with number, booleans, and nil, instance construction should be via LuaValue.valueOf(byte[]) or similar API.

Because of this pooling, users of LuaString must not directly alter the bytes in a LuaString, or undefined behavior will result.

When Java Strings are used to initialize LuaString data, the UTF8 encoding is assumed. The functions lengthAsUtf8(char[]), encodeToUtf8(char[], int, byte[], int), and decodeAsUtf8(byte[], int, int) are used to convert back and forth between UTF8 byte arrays and character arrays.

See Also: