BaseUwU is a THICCCC binary to text encowoding using only UwU
s and OwO
s for maxium communication clarity among furries and weebs.
It's extremely inefficent — THICCCC with four C's, that is — at 24 output bytes per input byte. It's the perfect fit for projects which require maxium inefficiency!
This is a single header C library, in the style of an STB library. It does not need support for any C standard library functions if you provide a custom malloc
-compatible function; otherwise, it only requires that malloc
is available.
To include the library implementation, define BASE_UWU_IMPLEMENTATION
before #include
ing the file:
#define BASE_UWU_IMPLEMENTATION
#include "baseuwu.h"
Otherwise, just include baseuwu.h
.
To specify a custom memory allocation function, define BASE_UWU_ALLOC(x)
before including the implementation:
#define BASE_UWU_IMPLEMENTATION
#define BASE_UWU_ALLOC(x) MyCustomAlloc(x)
#include "baseuwu.h"
The default malloc
is used if one is not specified.
To encode, use UwU_Encode
:
// Declaration for UwU_Encode
int UwU_Encode(size_t input_size, const uint8_t *input_data, char **output_data_pointer);
void something() {
char data[] = "Hello, world!";
char *output; // The pointer to the resulting data is stored here.
// Encode the binary data
int status = UwU_Encode(strlen(data) + 1, data, output);
if (status) {
// Handle error...
}
printf("Output: %s\n", output);
free(output);
}
To decode data, use UwU_Decode
:
// Declaration for UwU_Decode
int UwU_Decode(const char *input_data, size_t *output_size_ptr, const uint8_t **output_data_ptr);
void something() {
char data[] = "OwOUwUOwOOwOUwUOwOOwOOwOOwOUwUUwUOwOOwOUwUOwOUwUOwOUwUUwUUwUOwOUwUUwUUwUOwOUwUUwUUwUOwOUwUUwUUwUOwOUwUUwUOwOUwUUwUUwUUwUOwOOwOUwUOwOOwOOwOOwOUwUOwOOwOUwUOwOOwOOwOOwOOwOOwOOwOUwUUwUUwUOwOUwUOwOOwOOwOUwUUwUOwOOwOUwUUwUOwOOwOOwOOwOOwOOwOOwOOwO";
size_t output_size; // The size of the loaded data is stored here
char *output_data; // The pointer to the loaded data is stored here
// Decode the text data
int status = UwU_Decode(data, &output_size, &output_data);
if (status) {
// Handle error ...
}
// NOTE: This assumes that the NUL byte was kept at the end of the encoded data.
printf("Decoded: %s (length = %x)\n", output_data, output_size);
free(output_data);
}
Don't. Or do. I don't care, really.
¯\_(ツ)_/¯
No.