diff --git a/README.md b/README.md index cad4e5a..d1d227a 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/hex/README.md b/hex/README.md index cdfa2d5..a512dc8 100644 --- a/hex/README.md +++ b/hex/README.md @@ -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 and should be encoded") -print(s) -dGhpcyBpcyBhIDx0YWc-IGFuZCBzaG91bGQgYmUgZW5jb2RlZA - -s = hex.URLEncoding:encode_to_string("this is a and should be encoded") -print(s) -dGhpcyBpcyBhIDx0YWc-IGFuZCBzaG91bGQgYmUgZW5jb2RlZA== +666f6f01626172 ``` @@ -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 ```