Skip to content

C implementation of base256 (a binary-to-emoji encoding).

License

Notifications You must be signed in to change notification settings

Equim-chan/libb256

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

libb256

Travis

C implementation of base256.

Install

$ git clone https://github.com/Equim-chan/libb256.git
$ cd libb256/build
$ cmake ..
$ make
$ [sudo] make install

This will by defaults build a static linked library, if you want a shared one, specify -DWITH_SHARED=1 in cmake.

Example

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <base256.h>

int main(void)
{
    // Encode a string
    char* plain = "Hello, 世界";
    int plain_size = strlen(plain);
    int encoded_size = BASE256_ENCODED_SIZE(plain_size);
    char* encoded = (char*)malloc(encoded_size);

    int n = base256_encode(encoded, encoded_size, (unsigned char*)plain, plain_size);
    if (n < 0) {
        return n;
    }

    puts(encoded); //=> 👾🍧🙆🍬🙇🌱😌🚟💦🏥🐴🏤👈

    // And decode it back
    int decoded_size = BASE256_DECODED_SIZE(encoded_size);
    char* decoded = (char*)malloc(decoded_size);

    base256_init_dec();
    n = base256_decode((unsigned char*)decoded, encoded_size, encoded);
    if (n < 0) {
        return n;
    }

    puts(decoded); //=> Hello, 世界

    return 0;
}

Documents

Please refer to libb256(3).

License

BSD-3-clause

About

C implementation of base256 (a binary-to-emoji encoding).

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages