diff options
author | antirez <antirez@gmail.com> | 2018-09-11 16:04:25 +0200 |
---|---|---|
committer | antirez <antirez@gmail.com> | 2018-09-11 16:04:25 +0200 |
commit | 65ce839d09ca3045ef94a10e441622dbb7fe36aa (patch) | |
tree | 39a2597391d6f19263c56faef9594d121235b00f /src/lolwut.c | |
parent | cb51bb4320d2240001e8fc4a522d59fb28259703 (diff) | |
download | redis-65ce839d09ca3045ef94a10e441622dbb7fe36aa.tar.gz |
LOLWUT: Emit Braille unicode according to pixel pattern.
Diffstat (limited to 'src/lolwut.c')
-rw-r--r-- | src/lolwut.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/lolwut.c b/src/lolwut.c new file mode 100644 index 000000000..5cef96f33 --- /dev/null +++ b/src/lolwut.c @@ -0,0 +1,23 @@ +/* Translate a group of 8 pixels (2x8 vertical rectangle) to the corresponding + * braille character. The byte should correspond to the pixels arranged as + * follows, where 0 is the least significant bit, and 7 the most significant + * bit: + * + * 0 3 + * 1 4 + * 2 5 + * 6 7 + * + * The corresponding utf8 encoded character is set into the three bytes + * pointed by 'output'. + */ +#include <stdio.h> +void lwEmitPixelsGroup(int byte, char *output) { + int code = 0x2800 + byte; + /* Convert to unicode. This is in the U0800-UFFFF range, so we need to + * emit it like this in three bytes: + * 1110xxxx 10xxxxxx 10xxxxxx. */ + output[1] = 0xE0 | (code >> 12); /* 1110-xxxx */ + output[2] = 0x80 | ((code >> 6) & 0x3F); /* 10-xxxxxx */ + output[3] = 0x80 | (code & 0x3F); /* 10-xxxxxx */ +} |