Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ go get github.com/vadv/gopher-lua-libs
* [db](/db) access to databases
* [filepath](/filepath) path.filepath port
* [goos](/goos) os port
* [hex](/hex) Port of [encoding/hex](https://pkg.go.dev/encoding/hex)
* [http](/http) http.client && http.server
* [humanize](/humanize) humanize [github.com/dustin/go-humanize](https://github.com/dustin/go-humanize) port
* [inspect](/inspect) pretty print [github.com/kikito/inspect.lua](https://github.com/kikito/inspect.lua)
Expand Down
20 changes: 4 additions & 16 deletions hex/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,9 @@ Lua module for [encoding/hex](https://pkg.go.dev/encoding/hex)
```lua
local hex = require("hex")

s = hex.RawStdEncoding:encode_to_string("foo\01bar")
s = hex:encode_to_string("foo\01bar")
print(s)
Zm9vAWJhcg

s = hex.StdEncoding:encode_to_string("foo\01bar")
print(s)
Zm9vAWJhcg==

s = hex.RawURLEncoding:encode_to_string("this is a <tag> and should be encoded")
print(s)
dGhpcyBpcyBhIDx0YWc-IGFuZCBzaG91bGQgYmUgZW5jb2RlZA

s = hex.URLEncoding:encode_to_string("this is a <tag> and should be encoded")
print(s)
dGhpcyBpcyBhIDx0YWc-IGFuZCBzaG91bGQgYmUgZW5jb2RlZA==
666f6f01626172

```

Expand All @@ -32,12 +20,12 @@ dGhpcyBpcyBhIDx0YWc-IGFuZCBzaG91bGQgYmUgZW5jb2RlZA==
```lua
local hex = require 'hex'

decoded, err = hex.decode_string("666f6f62617262617a")
decoded, err = hex.decode_string("666f6f01626172")
assert(not err, err)
print(decoded)
foobar

encoded = hex.encode_to_string(decoded)
print(encoded)
666f6f62617262617a
666f6f01626172
```