Skip to content

Commit

Permalink
sjis2utf8: use sjis_fgetc function
Browse files Browse the repository at this point in the history
  • Loading branch information
vampirefrog committed Nov 17, 2024
1 parent e934348 commit b0d7870
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions sjis2utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,9 @@ int main(int argc, char **argv) {

int last_byte = 0;
int b = 0;
while((b = fgetc(in)) != EOF) {
if(last_byte == 0 && SJIS_FIRST_CHAR(b)) {
last_byte = b;
} else {
utf8_fputc(sjis_char_to_unicode((last_byte << 8) | b), out);
last_byte = 0;
}
while((b = sjis_fgetc(in)) != EOF) {
if(b == -2) fprintf(stderr, "Invalid char found at %d\n", ftell(in));
utf8_fputc(sjis_char_to_unicode(b), out);
}

return 0;
Expand Down

0 comments on commit b0d7870

Please sign in to comment.