tutf8e

Tiny UTF-8 Encoder for C

MIT License

Stars
11

tutf8e

Tute Feighty

A tiny UTF-8 encoder for C.

Goals

  • As small and fast as possible
  • Narrowly scoped to one-step UTF-8 encoding in C
  • Link only what you need and use
  • MIT licence

Supported Encodings

Test Procedure

$ ./codegen.py

$ gcc src/* test/test.c -Iinclude

$ ./a.out
A quick brown fox jumps over the lazy dog
Nech ji hn saxofony bl rozezvu s dsnmi tny waltzu, tanga a quickstepu.
Pijamal hasta yaz ofre abucak gvendi.
Pdur Zagrebi tellomngija-fljetonist Ciqo klmetas kehvas garaais
     ? ,   !
        
       
Pijamal hasta yaz ofre abucak gvendi.
Flygande bckasiner ska hwila p mjuka tuvor.
         
Jeu kltw, spd Finom cz gry hab!
11 passed, 0 failed tests

How small is it?

512 bytes + overhead per encoding.

$ for i in src/*; do gcc -c $i -O1; done
$ du -bhc *.o | grep total
32K total

$ for i in src/*; do gcc -c $i -O3; done
$ du -bhc *.o | grep total
32K total

$ for i in src/*; do gcc -c $i -Os; done
$ du -bhc *.o | grep total
28K total

Related

Related Projects