summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/xelatex/xecjk/make-tbl-file/utf2gbk.tex
blob: aef2d51d9090540863e4c509629b1210f3dcc882 (plain)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
%
%  convert tbl files:
%
%  UTF --> gbk 

\documentclass[12pt]{article}
\begin{document}
\makeatletter

\@tempcnta "080\relax
  \loop
    \catcode\@tempcnta \active
    \ifnum\@tempcnta < "0FE\relax
      \advance\@tempcnta \@ne
  \repeat

\newwrite\fdout

\def\punctnumber#1#2#3#4#5{
\expandafter\def\csname punct@#1#2#3\endcsname{\string#4\string#5}}

\input{gbklist.tex}

\def\UTFpunct#1#2#3#4\relax{
\immediate\write\fdout{\string\GBKpunct\space\csname
   punct@\number `#1\number`#2\number`#3\endcsname#4\relax}}

\def\UTFpunctbreak#1#2#3#4\relax{
\immediate\write\fdout{\string\GBKpunctbreak\space\csname
   punct@\number `#1\number`#2\number`#3\endcsname#4\relax}}

\def\UTFkern#1#2#3#4#5#6#7\relax{
\immediate\write\fdout{\string\GBKkern\space\csname
   punct@\number `#1\number`#2\number`#3\endcsname
   \csname
   punct@\number `#4\number`#5\number`#6\endcsname
   #7\relax}}

\def\xeCJK@defkern{\immediate\write\fdout{\string\xeCJK@defkern}}


\def\tblversion{2008/06/20}

\bgroup
\catcode`\%=11
\catcode`\{=11
\catcode`\}=11
\catcode`\(=1
\catcode`\)=2
\global\def\percent(%)
\global\def\lbrace({)
\global\def\rbrace(})
\egroup



\def\outputtblfileheader{
  \immediate\write\fdout{\percent\space }
  \immediate\write\fdout{\percent\space This is the file \gbktblfilename.tbl\space version
  \tblversion}
  \bgroup
  \count@\time
  \divide\count@ 60
  \count2=-\count@
  \multiply\count2 60
  \advance\count2 \time
  \edef\today{%
    \the\year/\two@digits{\the\month}/\two@digits{\the\day}%
    \space\space at\space
      \two@digits{\the\count@}:\two@digits{\the\count2}}
  \immediate\write\fdout{\percent\space This is a generated file [\today].}
  \egroup
  \immediate\write\fdout{\percent\space Do not modify it!}
  \immediate\write\fdout{\percent\space }
  \immediate\write\fdout{\percent\space }
  \immediate\write\fdout{\percent\space Note:}
  \immediate\write\fdout{\percent\space\space\space    1) 'rule' is the width of the \string\vrule\space prepended/appended to the char.}
  \immediate\write\fdout{\percent\space\space\space     2) 'flag,sp,st,sh' means 'flag,space,stretch,shrink', the glue is}
  \immediate\write\fdout{\percent\space\space\space   defined by:  'space'em plus 'stretch'em minus 'shrink'em}
  \immediate\write\fdout{\percent\space\space\space  (it is ignored when flag is not 1).}
  \immediate\write\fdout{\percent\space\space\space    3) 'nbflag' means 'nobreak flag'.}
  \immediate\write\fdout{\percent\space\space\space    4) For more information on the tbl file, we refer to the CCT package.}
  \immediate\write\fdout{\percent\space\space\space   set rule to '0', pre glue to '0,0,0,0', post glue to '0,-0.2,0,0.2'.}
  \immediate\write\fdout{\percent\space\space\space}
  \immediate\write\fdout{\percent\space\space\space                 pre \space\space\space\space\space\space\space              post}
  \immediate\write\fdout{\percent\space\space\space      ------------------------------  ------------------------------}
  \immediate\write\fdout{\percent\space\space\space                    glue \space\space\space\space\space\space              glue}
  \immediate\write\fdout{\percent\space\space\space     char  nbflag  rule    (flag,sp,st,sh) nbflag  rule    (flag,sp,st,sh)}
  \immediate\write\fdout{\percent\space\space\space     ----  ------------------------------  ------------------------------}
}


\def\punctstyle#1{
  \ifcsname xeCJK@ps@#1\endcsname
    \edef\xeCJK@pstyle{\csname xeCJK@ps@#1\endcsname}
  \else
    \typeout{Warning: Punctstyle #1\space is not defined.}
  \fi}

\def\xeCJK@ps@kaiming{k}
\def\xeCJK@ps@banjiao{b}
\def\xeCJK@ps@quanjiao{q}
\def\xeCJK@ps@CCT{c}

\def\makegbktbl#1#2#3{
\punctstyle{#1}
\edef\gbktblfilename{gbk\xeCJK@pstyle#3}
\immediate\openout\fdout=\gbktblfilename.tbl
\outputtblfileheader
\immediate\write\fdout{\percent}
\immediate\write\fdout{\percent\space \space  \string\punctstyle{#1}}
\immediate\write\fdout{\percent}
\immediate\write\fdout{\string\expandafter\string\gdef\string\csname\space
           xeCJK@\gbktblfilename\string\endcsname\lbrace\percent}
\input{chs\xeCJK@pstyle#2.tbl}

\csname xeCJK@chs\xeCJK@pstyle#2\endcsname

\immediate\write\fdout{\rbrace\percent}
\immediate\write\fdout{\string\endinput}
\immediate\closeout\fdout}

\def\makegbktbls#1#2{
\makegbktbl{CCT}{#1}{#2}
\makegbktbl{banjiao}{#1}{#2}
\makegbktbl{quanjiao}{#1}{#2}
\makegbktbl{kaiming}{#1}{#2}}


\makegbktbls{simsun}{song}
\makegbktbls{simhei}{hei}
\makegbktbls{lisu}{li}
\makegbktbls{youyuan}{you}
\makegbktbls{kaiti}{kai}
\makegbktbls{fangsong}{fs}
\makegbktbls{def}{def}


\end{document}