In C, I'd be able to do something like this:
short number = 20693; // Create the number
unsigned char* str = malloc(3); // Create the string
memcpy(str, &number, 2); // Copy the number to the string
str[2] = 0; // 0-pad it
And then str
would contain the utf-8 representation of number
. Is it possible to do this in javascript (without the 0-padding)?