Human68k CUI emulator with sound.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sjis2utf8.c 451B

1234567891011121314151617181920212223
  1. #include <stdio.h>
  2. #include "sjis.h"
  3. #include "utf8.h"
  4. int main(int argc, char **argv) {
  5. FILE *in = stdin, *out = stdout;
  6. if(argc > 1) in = fopen(argv[1], "rb");
  7. if(argc > 2) out = fopen(argv[2], "rb");
  8. int last_byte = 0;
  9. int b = 0;
  10. while((b = fgetc(in)) != EOF) {
  11. if(last_byte == 0 && SJIS_FIRST_CHAR(b)) {
  12. last_byte = b;
  13. } else {
  14. utf8_fputc(sjis_char_to_unicode((last_byte << 8) | b), out);
  15. last_byte = 0;
  16. }
  17. }
  18. return 0;
  19. }