MCPcopy Create free account
hub / github.com/nodejs/nan / hex_encode

Function hex_encode

nan_string_bytes.h:206–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

204
205
206static size_t hex_encode(const char* src, size_t slen, char* dst, size_t dlen) {
207 // We know how much we'll write, just make sure that there's space.
208 assert(dlen >= slen * 2 &&
209 "not enough space provided for hex encode");
210
211 dlen = slen * 2;
212 for (uint32_t i = 0, k = 0; k < dlen; i += 1, k += 2) {
213 static const char hex[] = "0123456789abcdef";
214 uint8_t val = static_cast<uint8_t>(src[i]);
215 dst[k + 0] = hex[val >> 4];
216 dst[k + 1] = hex[val & 15];
217 }
218
219 return dlen;
220}
221
222
223

Callers 1

EncodeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected