lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Am 19.06.12 14:59, schrieb Patrick Rapin:
> Essentially as an exercise, I tried to write the smaller possible
> UTF-8 encoder in Lua [1].
> Compared to a naive implementation like in [2], it is around 2.6 times shorter.
> Still, I am wondering if the code could be further shorted (not
> counting space removal).
> [1]
> [2]  (and that implementation doesn't
> handle 4 bytes codes)

Maybe I am cheating a bit, but if write a binding to the FcUcs4ToUtf8()
function from fontconfig, it could be smaller.   But then, it is not
implemented in Lua (which you probably want)

#include <fontconfig.h>

int FcUcs4ToUtf8(FcChar32 src);