1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
|
/* Copyright 1993,94 H.Ogasawara (COR.) */
/* v1.10 1994 3/19 Ogasawara Hiroyuki */
/* oga@dgw.yz.yamagata-u.ac.jp */
#include "kanjicode.h"
#include "ackstring.h"
SjisEucCheck( ptr, len, cp )
unsigned char *ptr;
T_KANJI *cp;
{
unsigned char *endp= ptr+len;
int sjis= 0, euc= 0, step;
for(; ptr < endp ; ptr+= step ){
step= 1;
if( *ptr < 0x80 )
continue;
if( *ptr < 0xa0 ){
if( *ptr == 0x8e && IsKana( ptr[1] ) ){
euc+= 2; /* single shift */
step= 2;
}
if( IsSjis2( ptr[1] ) ){
sjis+= 2;
step= 2;
}
continue;
}
if( *ptr < 0xe0 ){
sjis++;
if( IsEuc2( ptr[1] ) ){
step= 2;
euc+= 2;
if( IsKana( ptr[1] ) )
sjis++;
}
continue;
}
if( *ptr < 0xf0 ){
if( IsEuc2( ptr[1] ) ){
step= 2;
euc+= 2;
}
if( IsSjis2( ptr[1] ) ){
step= 2;
sjis+= 2;
}
continue;
}
if( *ptr < 0xff && IsEuc2( ptr[1] ) ){
step= 2;
euc+= 2;
}
}
/*printf( "%d %d\n", sjis, euc );*/
cp->inpcode= sjis > euc ? SJIS : EUC;
}
|