Skip to content

The only furry compatible binary-to-text encoding

License

Notifications You must be signed in to change notification settings

knot126/BaseUwU

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BaseUwU logo

BaseUwU Binary to Text Encoding

BaseUwU is a THICCCC binary to text encowoding using only UwUs and OwOs 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!

Usage

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.

Including

To include the library implementation, define BASE_UWU_IMPLEMENTATION before #includeing 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.

Encoding

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);
}

Decoding

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);
}

Contributing

Don't. Or do. I don't care, really.

Code quality

¯\_(ツ)_/¯

Licence

No.