images.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include "images.h"
  4. #include <iconv.h>
  5. class IConv {
  6. iconv_t ic;
  7. public:
  8. IConv(const char *to, const char *from) : ic(iconv_open(to, from)) {}
  9. ~IConv() { iconv_close(ic); }
  10. int convert(char *input, char *output, size_t outbufsize) {
  11. size_t inbufsize = strlen(input);
  12. size_t orig_size = outbufsize;
  13. // memset(output, 0, outbufsize);
  14. // https://www.gnu.org/savannah-checkouts/gnu/libiconv/documentation/libiconv-1.15/iconv.3.html
  15. int r = iconv(ic, &input, &inbufsize, &output, &outbufsize);
  16. *output = 0;
  17. return r;
  18. }
  19. };
  20. IConv converter("UTF-8", "CP437");
  21. char display_line(char *line) {
  22. char output[1024];
  23. int len;
  24. converter.convert(line, output, sizeof(output));
  25. printf("%s\n", output);
  26. }
  27. int main() {
  28. int x;
  29. int size = (sizeof(skull) / sizeof(char *));
  30. for (x = 0; x < size; x++) {
  31. display_line(skull[x]);
  32. }
  33. fflush(stdout);
  34. getchar();
  35. printf("\n\n");
  36. size = (sizeof(skullblink) / sizeof(char *));
  37. for (x = 0; x < size; x++) {
  38. display_line(skullblink[x]);
  39. }
  40. fflush(stdout);
  41. getchar();
  42. printf("\n\n");
  43. size = (sizeof(ghead) / sizeof(char *));
  44. for (x = 0; x < size; x++) {
  45. display_line(ghead[x]);
  46. }
  47. fflush(stdout);
  48. getchar();
  49. printf("\n\n");
  50. size = (sizeof(ghost) / sizeof(char *));
  51. for (x = 0; x < size; x++) {
  52. display_line(ghost[x]);
  53. }
  54. fflush(stdout);
  55. getchar();
  56. printf("\n\n");
  57. size = (sizeof(wolf) / sizeof(char *));
  58. for (x = 0; x < size; x++) {
  59. display_line(wolf[x]);
  60. }
  61. fflush(stdout);
  62. getchar();
  63. printf("\n\n");
  64. size = (sizeof(panther) / sizeof(char *));
  65. for (x = 0; x < size; x++) {
  66. display_line(panther[x]);
  67. }
  68. fflush(stdout);
  69. getchar();
  70. printf("\n\n");
  71. size = (sizeof(bat) / sizeof(char *));
  72. for (x = 0; x < size; x++) {
  73. display_line(bat[x]);
  74. }
  75. fflush(stdout);
  76. getchar();
  77. printf("\n\n");
  78. return 0;
  79. }