在C语言中,我可以这样做:
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
那么str
将包含number
的utf-8表示。在javascript中是否可能做到这一点(不进行0填充)?