Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
65ce839d
Commit
65ce839d
authored
Sep 11, 2018
by
antirez
Browse files
LOLWUT: Emit Braille unicode according to pixel pattern.
parent
cb51bb43
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lolwut.c
0 → 100644
View file @
65ce839d
/* 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 */
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment