Created
November 7, 2020 21:53
-
-
Save promovicz/5cfb091a6a77d8739b4e7dede27c9c28 to your computer and use it in GitHub Desktop.
Converting binary data into Unicode Braille
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <errno.h> | |
| #include <locale.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <wchar.h> | |
| #include <unistd.h> | |
| int main(int argc, char **argv) { | |
| int res, i; | |
| char buf[64]; | |
| setlocale(LC_CTYPE, ""); | |
| while(1) { | |
| res = read(0, buf, sizeof(buf)); | |
| if(res == 0) { | |
| break; | |
| } | |
| if(res == -1) { | |
| if(errno == EAGAIN) { | |
| continue; | |
| } else { | |
| perror("read"); | |
| return 1; | |
| } | |
| } | |
| for(i = 0; i < res; i++) { | |
| wchar_t w = 0x2800 + (buf[i] & 0xFF); | |
| fputwc(w, stdout); | |
| } | |
| } | |
| fflush(stdout); | |
| return 0; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment