Software /
code /
prosody
Comparison
util/hex.lua @ 6384:3f4809d01783
util.hex: Use locals!
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 03 Sep 2014 00:37:41 +0200 |
parent | 6375:76d8907d5301 |
child | 6545:ec566d7cd518 |
comparison
equal
deleted
inserted
replaced
6382:57d23c26039b | 6384:3f4809d01783 |
---|---|
6 | 6 |
7 local function hex_to_char(h) | 7 local function hex_to_char(h) |
8 return s_char(tonumber(h, 16)); | 8 return s_char(tonumber(h, 16)); |
9 end | 9 end |
10 | 10 |
11 function to(s) | 11 local function to(s) |
12 return s:gsub(".", char_to_hex); | 12 return s:gsub(".", char_to_hex); |
13 end | 13 end |
14 | 14 |
15 function from(s) | 15 local function from(s) |
16 return s:gsub("..", hex_to_char); | 16 return s:gsub("..", hex_to_char); |
17 end | 17 end |
18 | 18 |
19 return { to = to, from = from } | 19 return { to = to, from = from } |