images.cpp 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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(const char *line) {
  22. char input[1024];
  23. char output[1024];
  24. int len;
  25. strcpy(input, line);
  26. converter.convert(input, output, sizeof(output));
  27. printf("%s\n", output);
  28. }
  29. int main() {
  30. int x;
  31. int size = (sizeof(skull) / sizeof(char *));
  32. for (x = 0; x < size; x++) {
  33. display_line(skull[x]);
  34. }
  35. fflush(stdout);
  36. getchar();
  37. printf("\n\n");
  38. size = (sizeof(skullblink) / sizeof(char *));
  39. for (x = 0; x < size; x++) {
  40. display_line(skullblink[x]);
  41. }
  42. fflush(stdout);
  43. getchar();
  44. printf("\n\n");
  45. size = (sizeof(ghead) / sizeof(char *));
  46. for (x = 0; x < size; x++) {
  47. display_line(ghead[x]);
  48. }
  49. fflush(stdout);
  50. getchar();
  51. printf("\n\n");
  52. size = (sizeof(ghost) / sizeof(char *));
  53. for (x = 0; x < size; x++) {
  54. display_line(ghost[x]);
  55. }
  56. fflush(stdout);
  57. getchar();
  58. printf("\n\n");
  59. size = (sizeof(wolf) / sizeof(char *));
  60. for (x = 0; x < size; x++) {
  61. display_line(wolf[x]);
  62. }
  63. fflush(stdout);
  64. getchar();
  65. printf("\n\n");
  66. size = (sizeof(panther) / sizeof(char *));
  67. for (x = 0; x < size; x++) {
  68. display_line(panther[x]);
  69. }
  70. fflush(stdout);
  71. getchar();
  72. printf("\n\n");
  73. size = (sizeof(bat) / sizeof(char *));
  74. for (x = 0; x < size; x++) {
  75. display_line(bat[x]);
  76. }
  77. fflush(stdout);
  78. getchar();
  79. printf("\n\n");
  80. return 0;
  81. }