Documentation
¶
Overview ¶
Package hex implements hex encode/decode functionality for lua.
Index ¶
- func DecodeString(L *lua.LState) int
- func EncodeToString(L *lua.LState) int
- func LVHexDecoder(L *lua.LState, reader io.Reader) lua.LValue
- func LVHexEncoder(L *lua.LState, writer io.Writer) lua.LValue
- func Loader(L *lua.LState) int
- func NewDecoder(L *lua.LState) int
- func NewEncoder(L *lua.LState) int
- func Preload(L *lua.LState)
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeString ¶
DecodeString decodes the encoded string with the encoding
Example ¶
state := lua.NewState() defer state.Close() Preload(state) source := ` local hex = require 'hex' s, err = hex.decode_string("666f6f01626172") assert(not err, err) print(s) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: foo�bar
func EncodeToString ¶
EncodeToString decodes the string with the encoding
Example ¶
state := lua.NewState() defer state.Close() Preload(state) source := ` local hex = require 'hex' s = hex.encode_to_string("foo\01bar") print(s) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: 666f6f01626172
func LVHexDecoder ¶
LVHexDecoder creates a new Lua user data for the hex decoder
func LVHexEncoder ¶
LVHexEncoder creates a new Lua user data for the hex encoder
func NewDecoder ¶
Example ¶
state := lua.NewState() defer state.Close() Preload(state) strings.Preload(state) source := ` local hex = require 'hex' local strings = require 'strings' local reader = strings.new_reader('666f6f01626172') decoder = hex.new_decoder(reader) local s = decoder:read("*a") print(s) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: foo�bar
func NewEncoder ¶
Example ¶
state := lua.NewState() defer state.Close() Preload(state) strings.Preload(state) source := ` local hex = require 'hex' local strings = require 'strings' local writer = strings.new_builder() encoder = hex.new_encoder(writer) encoder:write("foo\01bar") print(writer:string()) ` if err := state.DoString(source); err != nil { log.Fatal(err.Error()) }
Output: 666f6f01626172
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.