Giter Site home page Giter Site logo

baseuwu's Introduction

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.

baseuwu's People

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

burncastoon23

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.