summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Build/source/texk/mendexk/ChangeLog11
-rw-r--r--Build/source/texk/mendexk/Makefile.am5
-rw-r--r--Build/source/texk/mendexk/convert.c67
-rw-r--r--Build/source/texk/mendexk/fread.c14
-rw-r--r--Build/source/texk/mendexk/fwrite.c33
-rw-r--r--Build/source/texk/mendexk/kana.h13
-rw-r--r--Build/source/texk/mendexk/main.c34
-rw-r--r--Build/source/texk/mendexk/mendex.15
-rw-r--r--Build/source/texk/mendexk/mendex.doc4
-rw-r--r--Build/source/texk/mendexk/styfile.c12
-rwxr-xr-xBuild/source/texk/mendexk/tests/mendex.test9
-rw-r--r--Build/source/texk/mendexk/tests/uni.dict3
-rw-r--r--Build/source/texk/mendexk/tests/uni.idx8
-rw-r--r--Build/source/texk/mendexk/tests/uni.ind25
-rw-r--r--Build/source/texk/mendexk/tests/uni.ist10
15 files changed, 214 insertions, 39 deletions
diff --git a/Build/source/texk/mendexk/ChangeLog b/Build/source/texk/mendexk/ChangeLog
index 63dabfbdbc2..46d0c29a4a5 100644
--- a/Build/source/texk/mendexk/ChangeLog
+++ b/Build/source/texk/mendexk/ChangeLog
@@ -1,3 +1,14 @@
+2014-05-11 TANAKA Takuji <KXD02663@nifty.ne.jp>
+
+ * main.c: Add TeX Live version.
+ * {main,convert,fread,fwrite,styfile}.c, kana.h,
+ mendex.doc, mendex.1: Add a new option -I to switch
+ internal buffers for key words to EUC-JP or UTF-8.
+ * tests/mendex.test: Add a new test.
+ * tests/uni.{idx,dict,ist} (new): Test input.
+ * tests/uni.ind (new): Expected output.
+ * Makefile.am: Adapted.
+
2014-05-10 TANAKA Takuji <KXD02663@nifty.ne.jp>
* mendex.1: Fix usage.
diff --git a/Build/source/texk/mendexk/Makefile.am b/Build/source/texk/mendexk/Makefile.am
index b9f1dafa102..f27d2fb337c 100644
--- a/Build/source/texk/mendexk/Makefile.am
+++ b/Build/source/texk/mendexk/Makefile.am
@@ -56,6 +56,7 @@ TESTS = tests/mendex.test
EXTRA_DIST += $(TESTS)
## tests/mendex.test
-EXTRA_DIST += tests/foo.idx tests/foo.ind
-DISTCLEANFILES = foo.*
+EXTRA_DIST += tests/foo.idx tests/foo.ind \
+ tests/uni.idx tests/uni.dict tests/uni.ist tests/uni.ind
+ (%s)DISTCLEANFILES = foo.* uni.*
diff --git a/Build/source/texk/mendexk/convert.c b/Build/source/texk/mendexk/convert.c
index 4d6aff618a2..eae28c970e9 100644
--- a/Build/source/texk/mendexk/convert.c
+++ b/Build/source/texk/mendexk/convert.c
@@ -3,6 +3,8 @@
#include <kpathsea/tex-file.h>
#include <kpathsea/variable.h>
#include <ptexenc/ptexenc.h>
+#include <ptexenc/unicode.h>
+#include <ptexenc/unicode-jp.h>
#include "qsort.h"
@@ -21,6 +23,11 @@ static int dlines=0,elines=0;
static int dicvalread(const char *filename, struct dictionary *dicval, int line);
+#define is_katakana(a) ((strncmp((a),KATATOP,2)>=0) && (strncmp((a),KATAEND,2)<=0))
+#define is_hiragana(a) ((strncmp((a),HIRATOP,2)>=0) && (strncmp((a),HIRAEND,2)<=0))
+#define is_onbiki(a) (strncmp((a),ONBIKI,2)==0)
+#define is_alpha_numeric(a) ((strncmp((a),SPACE,2)>=0)&&(strncmp((a),ALPHAEND,2)<=0))
+
/* initialize kana table */
void initkanatable(void)
{
@@ -192,6 +199,8 @@ int convert(char *buff1, char *buff2)
{
int i=0,j=0,k,l;
char errbuff[4096];
+ int chr,wclen;
+ char buff3[3];
while(1) {
if (buff1[i]=='\0') {
@@ -199,6 +208,28 @@ int convert(char *buff1, char *buff2)
break;
}
else {
+ if ((unsigned char)buff1[i]<0x80)
+ wclen=1;
+ else if (is_internalUPTEX()) { /* convert a character from UTF8 to EUC */
+ wclen=multibytelen((unsigned char)buff1[i]);
+ if (wclen<0) {
+ verb_printf(efp,"\nWarning: Illegal lead byte 0x%x in UTF-8.", (unsigned char)buff1[i]);
+ i++;
+ continue;
+ }
+ chr = UCS2toJIS(UTF8StoUCS(&buff1[i]));
+ if (chr==0) chr = 0xffff; /* conversion failed */
+ chr |= 0x8080;
+ buff3[0]=BYTE3(chr);
+ buff3[1]=BYTE4(chr);
+ buff3[2]='\0';
+ } else {
+ wclen=2;
+ buff3[0]=buff1[i];
+ buff3[1]=buff1[i+1];
+ buff3[2]='\0';
+ }
+
if ((buff1[i]>='a')&&(buff1[i]<='z')) {
buff2[j]=buff1[i]-32;
i++;
@@ -215,41 +246,41 @@ int convert(char *buff1, char *buff2)
j++;
}
- else if ((strncmp(&buff1[i],KATATOP,2)>=0)&&(strncmp(&buff1[i],KATAEND,2)<=0)) {
+ else if (is_katakana(buff3)) {
/* katakana */
for (k=0;k<strlen(katakana);k+=2) {
- if (strncmp(&buff1[i],&katakana[k],2)==0) {
+ if (strncmp(buff3,&katakana[k],2)==0) {
strncpy(&buff2[j],&kanatable[k],2);
goto MATCH1;
}
}
- sprintf(errbuff,"\nError: %s is bad katakana ",&buff1[i]);
+ sprintf(errbuff,"\nError: %s is bad katakana ",buff3);
fputs(errbuff,efp);
if (efp!=stderr) fputs(errbuff,stderr);
return -1;
MATCH1:
- i+=2;
+ i+=wclen;
j+=2;
}
- else if ((strncmp(&buff1[i],HIRATOP,2)>=0)&&(strncmp(&buff1[i],HIRAEND,2)<=0)) {
+ else if (is_hiragana(buff3)) {
/* hiragana */
for (k=0;k<strlen(hiragana);k+=2) {
- if (strncmp(&buff1[i],&hiragana[k],2)==0) {
+ if (strncmp(buff3,&hiragana[k],2)==0) {
strncpy(&buff2[j],&kanatable[k],2);
goto MATCH2;
}
}
- sprintf(errbuff,"\nError: %s is bad hiragana ",&buff1[i]);
+ sprintf(errbuff,"\nError: %s is bad hiragana ",buff3);
fputs(errbuff,efp);
if (efp!=stderr) fputs(errbuff,stderr);
return -1;
MATCH2:
- i+=2;
+ i+=wclen;
j+=2;
}
- else if (strncmp(&buff1[i],ONBIKI,2)==0) {
+ else if (is_onbiki(buff3)) {
/* onbiki */
if (j>=2) {
for (k=0;k<20;k+=2) {
@@ -266,25 +297,26 @@ MATCH2:
if (efp!=stderr) fputs(errbuff,stderr);
return -1;
MATCH3:
- i+=2;
+ i+=wclen;
j+=2;
}
else if ((unsigned char)buff1[i]>=0x80) {
- if ((strncmp(&buff1[i],SPACE,2)>=0)&&(strncmp(&buff1[i],ALPHAEND,2)<=0)) {
+ if (is_alpha_numeric(buff3)) {
/* alpha-numeric,symbols */
for (k=0;k<strlen(symboltable);k+=2) {
- if (strncmp(&buff1[i],&symboltable[k],2)==0) {
+ if (strncmp(buff3,&symboltable[k],2)==0) {
buff2[j]=k/2+0x20;
if ((buff2[j]>='a')&&(buff2[j]<='z')) buff2[j]-=32;
+ i+=wclen;
j++;
- i+=2;
break;
}
}
if (k==strlen(symboltable)) {
- buff2[j++]=buff1[i++];
- buff2[j++]=buff1[i++];
+ i+=wclen;
+ buff2[j++]=buff3[0];
+ buff2[j++]=buff3[1];
}
}
@@ -312,8 +344,9 @@ MATCH3:
if (((k==dlines)&&(elines==0))||((k==elines)&&(elines!=0))) {
if (force==1) {
/* forced convert */
- buff2[j++]=buff1[i++];
- buff2[j++]=buff1[i++];
+ i+=wclen;
+ buff2[j++]=buff3[0];
+ buff2[j++]=buff3[1];
}
else {
sprintf(errbuff,"\nError: %s is no entry in dictionary file ",&buff1[i]);
diff --git a/Build/source/texk/mendexk/fread.c b/Build/source/texk/mendexk/fread.c
index e183bca11a4..8ff2eb357f6 100644
--- a/Build/source/texk/mendexk/fread.c
+++ b/Build/source/texk/mendexk/fread.c
@@ -207,9 +207,17 @@ LOOP:
wbuff[k]=buff[j];
if (buff[j]!=escape) esc=0;
if ((unsigned char)buff[j]>=0x80) {
- wbuff[k+1]=buff[j+1];
- j++;
- k++;
+ int len = multibytelen((unsigned char)buff[j]);
+ if (len<0) {
+ verb_printf(efp,"\nWarning: Illegal input of lead byte 0x%x in UTF-8.",(unsigned char)buff[j]);
+ k--;
+ continue;
+ }
+ while(--len) {
+ wbuff[k+1]=buff[j+1];
+ j++;
+ k++;
+ }
}
}
ind[i].words=indent+1;
diff --git a/Build/source/texk/mendexk/fwrite.c b/Build/source/texk/mendexk/fwrite.c
index 77176ec8940..516e772db76 100644
--- a/Build/source/texk/mendexk/fwrite.c
+++ b/Build/source/texk/mendexk/fwrite.c
@@ -4,6 +4,8 @@
#include <kpathsea/tex-file.h>
#include <ptexenc/ptexenc.h>
+#include <ptexenc/unicode.h>
+#include <ptexenc/unicode-jp.h>
#include "exkana.h"
#include "exvar.h"
@@ -23,6 +25,25 @@ static void crcheck(char *lbuff, FILE *fp);
#define BUFFERLEN 4096
#define TAIL_LEN(x) ((x)+strlen(x)), (BUFFERLEN-strlen(x))
+void fprint_euc_char(FILE *fp, const char a, const char b)
+{
+ if (is_internalUPTEX()) { /* convert a character from EUC to UTF8 */
+ int k = 0;
+ unsigned char str[5];
+ int chr = (unsigned char)a<<8 | (unsigned char)b;
+ chr = (chr==0xffff) ? U_REPLACEMENT_CHARACTER : JIStoUCS2(chr & 0x7f7f);
+ chr = UCStoUTF8(chr);
+ /* if (BYTE1(chr) != 0) str[k++] = BYTE1(chr); */ /* do not happen */
+ if (BYTE2(chr) != 0) str[k++] = BYTE2(chr);
+ if (BYTE3(chr) != 0) str[k++] = BYTE3(chr);
+ str[k++] = BYTE4(chr);
+ str[k++] = '\0';
+ fprintf(fp,"%s",str);
+ }
+ else
+ fprintf(fp,"%c%c",a,b);
+}
+
/* fprintf with convert kanji code */
int fprintf2(FILE *fp, const char *format, ...)
{
@@ -72,6 +93,7 @@ void indwrite(char *filename, struct index *ind, int pagenum)
int i,j,hpoint=0;
char datama[2048],lbuff[BUFFERLEN];
FILE *fp;
+ int conv_euc_to_euc;
if (filename[0]!='\0' && kpse_out_name_ok(filename)) fp=fopen(filename,"wb");
else {
@@ -81,7 +103,10 @@ void indwrite(char *filename, struct index *ind, int pagenum)
#endif
}
+ conv_euc_to_euc = is_internalUPTEX() ? 1 : 0;
+ if (conv_euc_to_euc) set_enc_string(NULL, "euc");
convert(atama,datama);
+ if (conv_euc_to_euc) set_enc_string(NULL, "uptex");
fputs(preamble,fp);
if (fpage>0) {
@@ -118,13 +143,13 @@ void indwrite(char *filename, struct index *ind, int pagenum)
fputs(lethead_prefix,fp);
for (j=hpoint;j<(strlen(datama)/2);j++) {
if ((unsigned char)ind[i].dic[0][1]<(unsigned char)datama[j*2+1]) {
- fprintf(fp,"%c%c",atama[(j-1)*2],atama[(j-1)*2+1]);
+ fprint_euc_char(fp,atama[(j-1)*2],atama[(j-1)*2+1]);
hpoint=j;
break;
}
}
if (j==(strlen(datama)/2)) {
- fprintf(fp,"%c%c",atama[(j-1)*2],atama[(j-1)*2+1]);
+ fprint_euc_char(fp,atama[(j-1)*2],atama[(j-1)*2+1]);
}
fputs(lethead_suffix,fp);
}
@@ -187,7 +212,7 @@ void indwrite(char *filename, struct index *ind, int pagenum)
fputs(group_skip,fp);
if (lethead_flag!=0) {
fputs(lethead_prefix,fp);
- fprintf(fp,"%c%c",atama[(j-1)*2],atama[(j-1)*2+1]);
+ fprint_euc_char(fp,atama[(j-1)*2],atama[(j-1)*2+1]);
fputs(lethead_suffix,fp);
}
}
@@ -196,7 +221,7 @@ void indwrite(char *filename, struct index *ind, int pagenum)
fputs(group_skip,fp);
if (lethead_flag!=0) {
fputs(lethead_prefix,fp);
- fprintf(fp,"%c%c",ind[i].dic[0][0],ind[i].dic[0][1]);
+ fprint_euc_char(fp,ind[i].dic[0][0],ind[i].dic[0][1]);
fputs(lethead_suffix,fp);
}
}
diff --git a/Build/source/texk/mendexk/kana.h b/Build/source/texk/mendexk/kana.h
index 7ad88383b9e..34c17016a1d 100644
--- a/Build/source/texk/mendexk/kana.h
+++ b/Build/source/texk/mendexk/kana.h
@@ -13,6 +13,19 @@ char AKASATANA[]={
0xa4,0xef, /* わ */
0
};
+char AKASATANAutf8[]={
+ 0xe3,0x81,0x82, /* あ */
+ 0xe3,0x81,0x8b, /* か */
+ 0xe3,0x81,0x95, /* さ */
+ 0xe3,0x81,0x9f, /* た */
+ 0xe3,0x81,0xaa, /* な */
+ 0xe3,0x81,0xaf, /* は */
+ 0xe3,0x81,0xbe, /* ま */
+ 0xe3,0x82,0x84, /* や */
+ 0xe3,0x82,0x89, /* ら */
+ 0xe3,0x82,0x8f, /* わ */
+ 0
+};
char *akasatana;
char AIUEO[]={
diff --git a/Build/source/texk/mendexk/main.c b/Build/source/texk/mendexk/main.c
index 13cda874e7e..52a093e9353 100644
--- a/Build/source/texk/mendexk/main.c
+++ b/Build/source/texk/mendexk/main.c
@@ -20,6 +20,7 @@ char *styfile,*idxfile[256],indfile[256],*dicfile,logfile[256];
KpathseaSupportInfo kp_ist,kp_dict;
#define VERSION "version 2.6f [14-Aug-2009]"
+#define TL_VERSION "TeX Live 2014"
int main(int argc, char **argv)
{
@@ -27,7 +28,7 @@ int main(int argc, char **argv)
const char *envbuff;
char *p;
- enable_UPTEX (false); /* disable */
+ enable_UPTEX (true); /* enable */
#ifdef WIN32
_setmaxstdio(2048);
@@ -176,25 +177,39 @@ int main(int argc, char **argv)
#endif
case 'U':
- set_enc_string("UTF8", NULL);
+ set_enc_string("UTF8", "uptex");
+ break;
+
+
+ case 'I':
+ if ((argv[i][2]=='\0')&&(i+1<argc)) {
+ i++;
+ if (strcmp(argv[i],"euc")==0) set_enc_string(NULL, "euc");
+ else if (strcmp(argv[i],"utf8")==0) set_enc_string(NULL, "uptex");
+ }
+ else {
+ if (strcmp(&argv[i][2],"euc")==0) set_enc_string(NULL, "euc");
+ else if (strcmp(&argv[i][2],"utf8")==0) set_enc_string(NULL, "uptex");
+ }
break;
default:
- fprintf(stderr,"mendex - Japanese index processor, %s (%s).\n",VERSION, get_enc_string());
+ fprintf(stderr,"mendex - Japanese index processor, %s (%s) (%s).\n",VERSION, get_enc_string(), TL_VERSION);
fprintf(stderr," Copyright 2009 ASCII MEDIA WORKS.(ptex-staff@ml.asciimw.jp)\n");
fprintf(stderr,"usage:\n");
fprintf(stderr,"%% mendex [-ilqrcgfEJS"
#ifdef WIN32
"T"
#endif
- "U] [-s sty] [-d dic] [-o ind] [-t log] [-p no] [idx0 idx1 ...]\n");
+ "U] [-s sty] [-d dic] [-o ind] [-t log] [-p no] [-I enc] [idx0 idx1 ...]\n");
fprintf(stderr,"options:\n");
fprintf(stderr,"-i use stdin as the input file.\n");
fprintf(stderr,"-l use letter ordering.\n");
fprintf(stderr,"-q quiet mode.\n");
fprintf(stderr,"-r disable implicit page formation.\n");
fprintf(stderr,"-c compress blanks. (ignore leading and trailing blanks.)\n");
- fprintf(stderr,"-g make Japanese index head <%s>.\n", AKASATANA);
+ fprintf(stderr,"-g make Japanese index head <%s>.\n",
+ is_internalUPTEX() ? AKASATANAutf8 : AKASATANA);
fprintf(stderr,"-f force to output kanji.\n");
fprintf(stderr,"-s sty take sty as style file.\n");
fprintf(stderr,"-d dic take dic as dictionary file.\n");
@@ -208,6 +223,7 @@ int main(int argc, char **argv)
fprintf(stderr,"-T ShiftJIS terminal.\n");
#endif
fprintf(stderr,"-U UTF-8 mode.\n");
+ fprintf(stderr,"-I enc internal encoding for keywords (enc: euc or utf8).\n");
fprintf(stderr,"idx... input files.\n");
exit(0);
break;
@@ -265,12 +281,12 @@ int main(int argc, char **argv)
}
if (strcmp(argv[0],"makeindex")==0) {
- verb_printf(efp,"This is Not `MAKEINDEX\', But `MENDEX\' %s (%s).\n",
- VERSION, get_enc_string());
+ verb_printf(efp,"This is Not `MAKEINDEX\', But `MENDEX\' %s (%s) (%s).\n",
+ VERSION, get_enc_string(), TL_VERSION);
}
else {
- verb_printf(efp,"This is mendex %s (%s).\n",
- VERSION, get_enc_string());
+ verb_printf(efp,"This is mendex %s (%s) (%s).\n",
+ VERSION, get_enc_string(), TL_VERSION);
}
/* init kanatable */
diff --git a/Build/source/texk/mendexk/mendex.1 b/Build/source/texk/mendexk/mendex.1
index 48360700e90..c19f1cc53b4 100644
--- a/Build/source/texk/mendexk/mendex.1
+++ b/Build/source/texk/mendexk/mendex.1
@@ -4,7 +4,7 @@
.SH 名称
mendex \- 索引整形ツール
.SH 使用法
-\fBmendex\fR [-ilqrcgEJS] [\fB-s\fI sty\fR] [\fB-d\fI dic\fR] [\fB-o\fI ind\fR] [\fB-d\fI dic\fR] [\fB-t\fI log\fR] [\fB-p\fI no\fR] [\fI idx0 idx1 idx2 ...\fR]
+\fBmendex\fR [-ilqrcgEJS] [\fB-s\fI sty\fR] [\fB-d\fI dic\fR] [\fB-o\fI ind\fR] [\fB-d\fI dic\fR] [\fB-t\fI log\fR] [\fB-p\fI no\fR] [\fB-I\fI enc\fR] [\fI idx0 idx1 idx2 ...\fR]
.SH 解説
.PP
\fImendex\fR は文書の索引を作成するツールです。 LaTeX により抽出された索引リストファイル(\fI.idx\fR)を並べ替え、実際の索引のソースファイルの形に整形します。 \fImakeindex\fR と互換性があり、さらに「読み」の扱いの手間を減らすように特殊化されています。
@@ -62,6 +62,9 @@ mendex \- 索引整形ツール
.TP 10
\fB-U\fR
漢字コードをUTF-8に指定します。入力ファイル、出力ファイルともUTF-8として扱います。
+.TP 10
+\fB-I\fI enc\fR
+内部バッファのコードを\fIenc\fR に指定します。\fIenc\fR には \fIeuc\fR(EUC-JP) または \fIutf8\fR(UTF-8)が指定可能です。
.SH スタイルファイル
diff --git a/Build/source/texk/mendexk/mendex.doc b/Build/source/texk/mendexk/mendex.doc
index 1a3505df4f8..adae776fef8 100644
--- a/Build/source/texk/mendexk/mendex.doc
+++ b/Build/source/texk/mendexk/mendex.doc
@@ -4,7 +4,7 @@ mendex - 索引整形ツール
使用法
- mendex [-ilqrcgEJS] [-s sty] [-d dic] [-o ind] [-d dic] [-t log] [-p no] [idx0 idx1 idx2 ...]
+ mendex [-ilqrcgEJS] [-s sty] [-d dic] [-o ind] [-d dic] [-t log] [-p no] [-I enc] [idx0 idx1 idx2 ...]
解説
@@ -66,6 +66,8 @@ mendex - 索引整形ツール
-S 漢字コードをShiftJISに指定します。
入力ファイル、出力ファイルともShiftJISとして扱います。
+ -I enc 内部バッファのコードをencに指定します。enc には euc (EUC-JP) または utf8 (UTF-8)が指定可能です。
+
スタイルファイル
diff --git a/Build/source/texk/mendexk/styfile.c b/Build/source/texk/mendexk/styfile.c
index 9179a34904c..04189664099 100644
--- a/Build/source/texk/mendexk/styfile.c
+++ b/Build/source/texk/mendexk/styfile.c
@@ -165,8 +165,16 @@ static void convline(char *buff1, int start, char *buff2)
}
else if (cc==1) {
if ((unsigned char)buff1[i]>0x80) {
- buff2[j++]=buff1[i++];
- buff2[j]=buff1[i];
+ int len = multibytelen((unsigned char)buff1[i]);
+ if (len<0) {
+ verb_printf(efp,"\nWarning: Illegal input of lead byte 0x%x in UTF-8.", (unsigned char)buff1[i]);
+ continue;
+ }
+ while(len--) {
+ buff2[j++]=buff1[i++];
+ }
+ i--;
+ continue;
}
else if (buff1[i]=='\\') {
i++;
diff --git a/Build/source/texk/mendexk/tests/mendex.test b/Build/source/texk/mendexk/tests/mendex.test
index 6afaa17d92d..53988d1eab5 100755
--- a/Build/source/texk/mendexk/tests/mendex.test
+++ b/Build/source/texk/mendexk/tests/mendex.test
@@ -14,3 +14,12 @@ rm -f foo.*
cat $srcdir/tests/foo.idx | ./mendex >foo.ind2 2>foo.ilg2 \
&& diff $srcdir/tests/foo.ind foo.ind2 || exit 1
+./mendex -U -d $srcdir/tests/uni.dict -s $srcdir/tests/uni.ist \
+ $srcdir/tests/uni.idx -o uni.ind1 -t uni.ilg1 \
+ && diff $srcdir/tests/uni.ind uni.ind1 || exit 1
+
+cat $srcdir/tests/uni.idx | \
+ ./mendex -U -d $srcdir/tests/uni.dict -s $srcdir/tests/uni.ist \
+ >uni.ind2 2>uni.ilg2 \
+ && diff $srcdir/tests/uni.ind uni.ind2 || exit 1
+
diff --git a/Build/source/texk/mendexk/tests/uni.dict b/Build/source/texk/mendexk/tests/uni.dict
new file mode 100644
index 00000000000..36343dac17d
--- /dev/null
+++ b/Build/source/texk/mendexk/tests/uni.dict
@@ -0,0 +1,3 @@
+% -*- coding: utf-8 -*-
+ c
+羶
diff --git a/Build/source/texk/mendexk/tests/uni.idx b/Build/source/texk/mendexk/tests/uni.idx
new file mode 100644
index 00000000000..52a0b8ecea9
--- /dev/null
+++ b/Build/source/texk/mendexk/tests/uni.idx
@@ -0,0 +1,8 @@
+\indexentry{@罍薹紊}{1}
+\indexentry{帥@荀綣}{1}
+\indexentry{ゆ}{1}
+\indexentry{Mendex}{1}
+\indexentry{Mendex!ゃ潟鴻若}{1}
+\indexentry{Mendex!ゃ@---篏帥}{1}
+\indexentry{Mendex!ゃ@---篏帥!吾@---ラ膩}{1}
+\indexentry{Mendex!ゃ@---篏帥!吾@---綽膩}{1}
diff --git a/Build/source/texk/mendexk/tests/uni.ind b/Build/source/texk/mendexk/tests/uni.ind
new file mode 100644
index 00000000000..aa142686417
--- /dev/null
+++ b/Build/source/texk/mendexk/tests/uni.ind
@@ -0,0 +1,25 @@
+\begin{theindex}
+
+\centerline{\bfseries M }\par\nobreak
+ \item Mendex\leaders\hbox{$\cdot$}\hfill 1
+ \subitem ゃ潟鴻若\leaders\hbox{$\cdot$}\hfill 1
+ \subitem ---篏帥\leaders\hbox{$\cdot$}\hfill 1
+ \subsubitem ---綽膩\leaders\hbox{$\cdot$}\hfill 1
+ \subsubitem ---ラ膩\leaders\hbox{$\cdot$}\hfill 1
+
+ \indexspace
+
+\centerline{\bfseries }\par\nobreak
+ \item 荀綣\leaders\hbox{$\cdot$}\hfill 1
+
+ \indexspace
+
+\centerline{\bfseries }\par\nobreak
+ \item ゆ\leaders\hbox{$\cdot$}\hfill 1
+
+ \indexspace
+
+\centerline{\bfseries }\par\nobreak
+ \item 罍薹紊\leaders\hbox{$\cdot$}\hfill 1
+
+\end{theindex}
diff --git a/Build/source/texk/mendexk/tests/uni.ist b/Build/source/texk/mendexk/tests/uni.ist
new file mode 100644
index 00000000000..095533d1fb3
--- /dev/null
+++ b/Build/source/texk/mendexk/tests/uni.ist
@@ -0,0 +1,10 @@
+% -*- coding: utf-8 -*-
+
+delim_0 "\\leaders\\hbox{$\\cdot$}\\hfill "
+delim_1 "\\leaders\\hbox{$\\cdot$}\\hfill "
+delim_2 "\\leaders\\hbox{$\\cdot$}\\hfill "
+
+lethead_flag 1
+lethead_prefix "\n\\centerline{\\bfseries "
+lethead_suffix " }\\par\\nobreak"
+