Backport from xs.

This commit is contained in:
default 2023-04-10 09:14:44 +02:00
parent 578d70ddc0
commit 74098ec443
2 changed files with 14 additions and 1 deletions

View file

@ -6,6 +6,7 @@
xs_str *xs_hex_enc(const xs_val *data, int size);
xs_val *xs_hex_dec(const xs_str *hex, int *size);
int xs_is_hex(const char *str);
xs_str *xs_base64_enc(const xs_val *data, int sz);
xs_val *xs_base64_dec(const xs_str *data, int *size);
xs_str *xs_utf8_enc(xs_str *str, unsigned int cpoint);
@ -65,6 +66,18 @@ xs_val *xs_hex_dec(const xs_str *hex, int *size)
}
int xs_is_hex(const char *str)
/* returns 1 if str is an hex string */
{
while (*str) {
if (strchr("0123456789abcdefABCDEF", *str++) == NULL)
return 0;
}
return 1;
}
xs_str *xs_base64_enc(const xs_val *data, int sz)
/* encodes data to base64 */
{

View file

@ -1 +1 @@
/* b4afa5f823a998a263159ebfe9be67b81a8cc774 */
/* 69d6e64d31491688ba4411e71c55e6c25482b17e */