§1  sjisconv (CJK Version 4.3.0)  FUNCTION AND USE 1

1. Function and Use.

This small program will convert SJIS encoded Japanese characters into a ‘preprocessed’ form. The need of this program arises from the fact that this encoding uses the characters ‘ ’, ‘ ’, and ‘ ’ which have special meanings in TEX.

Use this program as a filter:

2  THE PROGRAM  sjisconv (CJK Version 4.3.0) §2

2. The program.

The only function of this program is to replace all occurrences of SJIS encoded two byte characters with ( and are the first and the second byte of the character; represents the second byte as a decimal number).

Additionally we define a TEX macro at the very beginning to signal a preprocessed file.

The following code is very simple. No error detection is done because TEX which will see the output of complains loudly if something is wrong.

#include #include

int main(argc, argv ) int argc; char ∗argv [ ];

{int ch;

fprintf (stdout , );

ch = fgetc(stdin);

while (! feof (stdin))

{if ((ch ≥ ^{#}81 ∧ ch ≤ ^{#}9F) ∨ (ch ≥ ^{#}E0 ∧ ch ≤ ^{#}EF)) {fputc(ch, stdout );

ch = fgetc(stdin); if (! feof (stdin))

fprintf (stdout , , ch); } else

fputc(ch, stdout );

ch = fgetc(stdin); } exit ( ); return 0; /∗ never reached ∗/ }