UUID to hex stream/encoding

I would like to covert a given uuid
e.g.

e2c56db5-dffb-48d2-b060-d0f5a71096e0

to following hex string with this format

“\xE2\xC5\x6D\xB5\xDF\xFB\x48\xD2\xB0\x60\xD0\xF5\xA7\x10\x96\xE0”

How can I achieve this in squirrel ?

Here’s one way:

`function h2d(h) {
return h - ((h <= ‘9’) ? ‘0’ : ‘a’ - 10)
}

function uuid2hex(str1) {
local str2 = ""
for(local i = 0; i < str1.len(); i++) {
if(str1[i] == ‘-’) continue
local d = (h2d(str1[i]) << 4) | h2d(str1[i+1])
str2 = str2 + d.tochar()
i++
}
return str2
}

local s = uuid2hex(“e2c56db5-dffb-48d2-b060-d0f5a71096e0”)

local check = "“
foreach(c in s) check = check + format(”%02X ", c & 255)
server.log(check)
`