12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- #include <stdio.h>
- #include <string.h>
- #include "images.h"
- #include <iconv.h>
- class IConv {
- iconv_t ic;
- public:
- IConv(const char *to, const char *from) : ic(iconv_open(to, from)) {}
- ~IConv() { iconv_close(ic); }
- int convert(char *input, char *output, size_t outbufsize) {
- size_t inbufsize = strlen(input);
- size_t orig_size = outbufsize;
- // memset(output, 0, outbufsize);
- // https://www.gnu.org/savannah-checkouts/gnu/libiconv/documentation/libiconv-1.15/iconv.3.html
- int r = iconv(ic, &input, &inbufsize, &output, &outbufsize);
- *output = 0;
- return r;
- }
- };
- IConv converter("UTF-8", "CP437");
- void display_line(const char *line) {
- char input[1024];
- char output[1024];
- int len;
- strcpy(input, line);
- converter.convert(input, output, sizeof(output));
- printf("%s\n", output);
- }
- #define SHOW_IMAGE(img) \
- size = (sizeof(img) / sizeof(char *)); \
- for (x = 0; x < size; x++) \
- display_line(img[x]); \
- paws();
- void paws(void) {
- fflush(stdout);
- getchar();
- printf("\n\n");
- }
- int main() {
- int x;
- int size;
- SHOW_IMAGE(skull);
- SHOW_IMAGE(skullblink);
- SHOW_IMAGE(icu);
- SHOW_IMAGE(ghead);
- SHOW_IMAGE(ghost);
- SHOW_IMAGE(wolf);
- SHOW_IMAGE(panther);
- SHOW_IMAGE(bat);
- return 0;
- }
|