Move some stuff out of LuaStack
This commit is contained in:
@@ -850,6 +850,18 @@ static std::string_view read_number_x(const char *p, bool plus, bool minus, bool
|
||||
return sv::read_number(source, plus, minus, dec, exp);
|
||||
}
|
||||
|
||||
eng::string util::decode_token(uint64_t value) {
|
||||
static const char encoding[] =
|
||||
"\0_0123456789abcdefghijklmnopqrstuvwxyz";
|
||||
uint64_t n = value;
|
||||
char buffer[13] = {};
|
||||
for (int i = 11; i >= 0; i--) {
|
||||
buffer[i] = encoding[n % 38];
|
||||
n /= 38;
|
||||
}
|
||||
return eng::string(buffer);
|
||||
}
|
||||
|
||||
LuaDefine(unittests_util, "", "some unit tests") {
|
||||
// Test valid_hostname
|
||||
LuaAssert(L, sv::valid_hostname("foo123"));
|
||||
|
||||
Reference in New Issue
Block a user