images.cpp 1.8 KB

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