openresty / openresty/lua-resty-string

是否能支持hex2byte

Open
#57 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Lua
Stars
443
Forks
143
Avg merge
2h 31m
Merged PRs (30d)
1

Description

在lua-resty-string中已经实现to_hex,不知能否加一个from_hex,更加高效实现hex到byte的转换?
谢谢
我现在使用gsub的方式:

function from_hex(s)
    return (s:gsub('..', function(cc)
        return string.char(tonumber(cc, 16))
    end))
end

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by locating the existing to_hex implementation in lua-resty-string and review the reported gsub-based conversion for expected behavior. Add the requested from_hex utility as the inverse conversion, with behavior matching the issue's example; no test file is named in the report.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.