From d5a7bc26d70baba102295ca5f8120c7d1f223119 Mon Sep 17 00:00:00 2001 From: Takuji Tanaka Date: Mon, 13 Jun 2022 13:40:29 +0000 Subject: ptexenc: more strict check for UTF-8 git-svn-id: svn://tug.org/texlive/trunk@63574 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/texk/ptexenc/ptexenc.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Build') diff --git a/Build/source/texk/ptexenc/ptexenc.c b/Build/source/texk/ptexenc/ptexenc.c index e5f5e0f6cc4..db0a5e624d0 100644 --- a/Build/source/texk/ptexenc/ptexenc.c +++ b/Build/source/texk/ptexenc/ptexenc.c @@ -809,7 +809,7 @@ static int infile_enc[NOFILE]; /* ENC_UNKNOWN (=0): not determined /* guess file encoding */ /* - asumption: + assumption: No halfwidth katakana in Shift_JIS No SS2 nor SS3 in EUC-JP JIS X 0208 only and no platform dependent characters in Shift_JIS, EUC-JP @@ -930,8 +930,7 @@ char *ptenc_guess_enc(FILE *fp) continue; } cu8[pos_utf8] = k0; - pos_utf8++; - if (pos_utf8==len_utf8) { + if (pos_utf8==1) { if ((cu8[0]==0xE0 && cu8[1]<0xA0) || (cu8[0]==0xED && cu8[1]>0x9F) || (cu8[0]==0xF0 && cu8[1]<0x90)) { /* illegal combination in UTF-8 */ @@ -939,6 +938,9 @@ char *ptenc_guess_enc(FILE *fp) pos_utf8 = 0; continue; } + } + pos_utf8++; + if (pos_utf8==len_utf8) { #ifdef DEBUG for (i=0; i