Building $lb from C
I have a C string and I need to build a $lb from it.
This code works fine for strings shorter than 254 characters:
char *str = "some string";
int len = strlen(str);
int add = 2;
char *list = malloc(len + add + 1);
char lenChar = len + add;
sprintf(list, "%c\x01%s", lenChar, str);
Thought maybe someone can share the code for longer strings?
assuming, you are on a little-endian CPU and
then the length is as follows
And don't forget,
$lb(123) is not the same as $lb(1230/10), hence we have a $ls() function!