バグがあるけど気にするな。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdlib.h>
#include <jctype.h>
#include <mbstring.h>
#include <jstring.h>
#define JIS_MIN 0x2120L
#define JIS_MAX 0x7427L
#define PER_LINE 16 //1行の文字数
#define TRUE ((unsigned char)1)
#define FALSE ((unsigned char)0)
#define K_IN "\x1b\x24\x42"
#define K_OUT "\x1b\x28\x42"
int main()
{
typedef unsigned char BOOL;
FILE *fp;
char buf[3];
unsigned long i;
int j;
BOOL isPrintable;
fp = fopen("jis.txt","w");
if(!fp){
printf("fileopen error");
return EXIT_FAILURE;
}
//HEADER BEGIN
fprintf(fp,"JIS ");
if(PER_LINE<=16){
for(i=0;i<PER_LINE;i++)
fprintf(fp," +%X",i);
}
else{
for(i=0;i<16;i++)
fprintf(fp," +%X",i);
for(i=16;i<PER_LINE;i++)
fprintf(fp,"+%X",i);
}
//HEADER END
for(i=JIS_MIN; i < JIS_MAX + 1L ; i++){
if((i % PER_LINE) == 0L){
isPrintable = FALSE;
for(j=i ; j<i+PER_LINE;j++){
if(jisprint(jistojms(j))){
isPrintable = TRUE;
break;
}
}
if(isPrintable == FALSE){
i += PER_LINE;
}
else
fprintf(fp,"\n%X ",i);
}
if(isPrintable == TRUE){
*((unsigned short*)(buf)) = (unsigned short)i;
buf[2] = 0;
if(jisprint(jistojms(i)))
fprintf(fp,"%s%2s%s " , K_IN,buf,K_OUT);
else
fprintf(fp," ");
}
}
fclose(fp);
return EXIT_SUCCESS;
}