Debian Codegraph @

texmf-dist/tex/generic/enctex/utf8warn.tex

raw
1 % Warnings for all undeclared UTF-8 codes
2 % =======================================
3 % Petr+Mirek Olsak Sep. 2009
4
5 % Note: this file is an old version of utf8unkn.tex which is currently
6 % used by csplain by default (since Dec. 2012). If you are using
7 % csplain then you need not this file (utf8unkn.tex is preloaded already).
8 % This file is saved in enctex package only for archive purposes.
9 % Petr Olsak, May 2014
10
11 % Suppose, you are using encTeX for reading UTF-8 codes in input.
12 % Possibly, not all UTF-8 codes are declared by \mubyte..\endmubyte
13 % in your macros. You can do
14 %
15 % \input utf8warn
16 %
17 % in order to print warning messages for all undeclared UTF-8 codes
18 % scanned in input. The \mubytein have to be positive, of course.
19 %
20 % If undeclared UTF-8 code occures in input, the message
21 %
22 % WARNING: UTF-8 code <native-code> (^^hexa-code) is undeclared.
23 %
24 % will be printed on terminal and into log file. The \failedchar
25 % (implicitly defined as black box) will be printed into document.
26 %
27 % Example: WARNING: UTF-8 code “ (^^e2^^80^^9c) is undeclared
28 % means that double quote is not declared in your \mubyte table.
29 % You can correct it by adding (for example):
30 %
31 % \mubyte \leftqquote ^^e2^^80^^9c\endmubyte
32 % \def\leftqquote{``}
33
34 \ifx\mubyte\undefined
35 \message{SORRY: the encTeX have to be active to use this macro}
36 \endinput\fi
37
38 % \warntwobytes, \warnthreebytes etc. will be inserted by encTeX before
39 % all undeclared UTF-8 codes:
40
41 \mubyte \warntwobytes #2^^c0\endmubyte
42 \mubyte \warntwobytes #2^^c1\endmubyte
43 \mubyte \warntwobytes #2^^c2\endmubyte
44 \mubyte \warntwobytes #2^^c3\endmubyte
45 \mubyte \warntwobytes #2^^c4\endmubyte
46 \mubyte \warntwobytes #2^^c5\endmubyte
47 \mubyte \warntwobytes #2^^c6\endmubyte
48 \mubyte \warntwobytes #2^^c7\endmubyte
49 \mubyte \warntwobytes #2^^c8\endmubyte
50 \mubyte \warntwobytes #2^^c9\endmubyte
51 \mubyte \warntwobytes #2^^ca\endmubyte
52 \mubyte \warntwobytes #2^^cb\endmubyte
53 \mubyte \warntwobytes #2^^cc\endmubyte
54 \mubyte \warntwobytes #2^^cd\endmubyte
55 \mubyte \warntwobytes #2^^ce\endmubyte
56 \mubyte \warntwobytes #2^^cf\endmubyte
57 \mubyte \warntwobytes #2^^d0\endmubyte
58 \mubyte \warntwobytes #2^^d1\endmubyte
59 \mubyte \warntwobytes #2^^d2\endmubyte
60 \mubyte \warntwobytes #2^^d3\endmubyte
61 \mubyte \warntwobytes #2^^d4\endmubyte
62 \mubyte \warntwobytes #2^^d5\endmubyte
63 \mubyte \warntwobytes #2^^d6\endmubyte
64 \mubyte \warntwobytes #2^^d7\endmubyte
65 \mubyte \warntwobytes #2^^d8\endmubyte
66 \mubyte \warntwobytes #2^^d9\endmubyte
67 \mubyte \warntwobytes #2^^da\endmubyte
68 \mubyte \warntwobytes #2^^db\endmubyte
69 \mubyte \warntwobytes #2^^dc\endmubyte
70 \mubyte \warntwobytes #2^^dd\endmubyte
71 \mubyte \warntwobytes #2^^de\endmubyte
72 \mubyte \warntwobytes #2^^df\endmubyte
73
74 \mubyte \warnthreebytes #3^^e0\endmubyte
75 \mubyte \warnthreebytes #3^^e1\endmubyte
76 \mubyte \warnthreebytes #3^^e2\endmubyte
77 \mubyte \warnthreebytes #3^^e3\endmubyte
78 \mubyte \warnthreebytes #3^^e4\endmubyte
79 \mubyte \warnthreebytes #3^^e5\endmubyte
80 \mubyte \warnthreebytes #3^^e6\endmubyte
81 \mubyte \warnthreebytes #3^^e7\endmubyte
82 \mubyte \warnthreebytes #3^^e8\endmubyte
83 \mubyte \warnthreebytes #3^^e9\endmubyte
84 \mubyte \warnthreebytes #3^^ea\endmubyte
85 \mubyte \warnthreebytes #3^^eb\endmubyte
86 \mubyte \warnthreebytes #3^^ec\endmubyte
87 \mubyte \warnthreebytes #3^^ed\endmubyte
88 \mubyte \warnthreebytes #3^^ee\endmubyte
89 \mubyte \warnthreebytes #3^^ef\endmubyte
90
91 \mubyte \warnfourbytes #4^^f0\endmubyte
92 \mubyte \warnfourbytes #4^^f1\endmubyte
93 \mubyte \warnfourbytes #4^^f2\endmubyte
94 \mubyte \warnfourbytes #4^^f3\endmubyte
95 \mubyte \warnfourbytes #4^^f4\endmubyte
96 \mubyte \warnfourbytes #4^^f5\endmubyte
97 \mubyte \warnfourbytes #4^^f6\endmubyte
98 \mubyte \warnfourbytes #4^^f7\endmubyte
99
100 \mubyte \warnfivebytes #5^^f8\endmubyte
101 \mubyte \warnfivebytes #5^^f9\endmubyte
102 \mubyte \warnfivebytes #5^^fa\endmubyte
103 \mubyte \warnfivebytes #5^^fb\endmubyte
104
105 \mubyte \warnsixbytes #6^^fc\endmubyte
106 \mubyte \warnsixbytes #6^^fd\endmubyte
107
108 % \failedchar will be inserted to document instead the real character.
109 % It is defined as black box. You can re-define it, of course
110
111 \def\failedchar{\leavevmode
112 \kern.05em\vrule height.7em depth.1em width.4em\kern.05em }
113
114 % defs:
115
116 \def\warntwobytes #1#2{\utfwarnmessage{#1#2}}
117 \def\warnthreebytes #1#2#3{\utfwarnmessage{#1#2#3}}
118 \def\warnfourbytes #1#2#3#4{\utfwarnmessage{#1#2#3#4}}
119 \def\warnfivebytes #1#2#3#4#5{\utfwarnmessage{#1#2#3#4#5}}
120 \def\warnsixbytes #1#2#3#4#5#6{\utfwarnmessage{#1#2#3#4#5#6}}
121
122 \def\utfwarnmessage#1{\message{WARNING: UTF-8 code \printutfcode#1\end\space
123 (\printhexcode#1\end) is undefined.}\failedchar}
124
125 \def\printutfcode#1{\ifx#1\end\else \noconvert#1\expandafter\printutfcode\fi}
126
127 \def\printhexcode#1{\ifx#1\end\else^\empty^\hexx#1\expandafter\printhexcode\fi}
128
129 \def\hexx#1{\ifcase`#1 00\or 01\or 02\or 03\or 04\or 05\or 06\or 07\or
130 08\or 09\or 0a\or 0b\or 0c\or 0d\or 0e\or 0f\or
131 10\or 11\or 12\or 13\or 14\or 15\or 16\or 17\or
132 18\or 19\or 1a\or 1b\or 1c\or 1d\or 1e\or 1f\or
133 20\or 21\or 22\or 23\or 24\or 25\or 26\or 27\or
134 28\or 29\or 2a\or 2b\or 2c\or 2d\or 2e\or 2f\or
135 30\or 31\or 32\or 33\or 34\or 35\or 36\or 37\or
136 38\or 39\or 3a\or 3b\or 3c\or 3d\or 3e\or 3f\or
137 40\or 41\or 42\or 43\or 44\or 45\or 46\or 47\or
138 48\or 49\or 4a\or 4b\or 4c\or 4d\or 4e\or 4f\or
139 50\or 51\or 52\or 53\or 54\or 55\or 56\or 57\or
140 58\or 59\or 5a\or 5b\or 5c\or 5d\or 5e\or 5f\or
141 60\or 61\or 62\or 63\or 64\or 65\or 66\or 67\or
142 68\or 69\or 6a\or 6b\or 6c\or 6d\or 6e\or 6f\or
143 70\or 71\or 72\or 73\or 74\or 75\or 76\or 77\or
144 78\or 79\or 7a\or 7b\or 7c\or 7d\or 7e\or 7f\or
145 80\or 81\or 82\or 83\or 84\or 85\or 86\or 87\or
146 88\or 89\or 8a\or 8b\or 8c\or 8d\or 8e\or 8f\or
147 90\or 91\or 92\or 93\or 94\or 95\or 96\or 97\or
148 98\or 99\or 9a\or 9b\or 9c\or 9d\or 9e\or 9f\or
149 a0\or a1\or a2\or a3\or a4\or a5\or a6\or a7\or
150 a8\or a9\or aa\or ab\or ac\or ad\or ae\or af\or
151 b0\or b1\or b2\or b3\or b4\or b5\or b6\or b7\or
152 b8\or b9\or ba\or bb\or bc\or bd\or be\or bf\or
153 c0\or c1\or c2\or c3\or c4\or c5\or c6\or c7\or
154 c8\or c9\or ca\or cb\or cc\or cd\or ce\or cf\or
155 d0\or d1\or d2\or d3\or d4\or d5\or d6\or d7\or
156 d8\or d9\or da\or db\or dc\or dd\or de\or df\or
157 e0\or e1\or e2\or e3\or e4\or e5\or e6\or e7\or
158 e8\or e9\or ea\or eb\or ec\or ed\or ee\or ef\or
159 f0\or f1\or f2\or f3\or f4\or f5\or f6\or f7\or
160 f8\or f9\or fa\or fb\or fc\or fd\or fe\or ff\fi}
161
162 % You can use macro \relaxutfwarn if you are \edefing scanned text,
163 % because the scanned text may include the \warntwobytes
164 % etc. sequences inserted by encTeX. Example:
165 % \def\scansometext#1\par{{\relaxutfwarn\xdef\scanned{#1\scanned}...}...}
166
167 \def\relaxutfwarn{\let\warntwobytes=\relax \let\warnthreebytes=\relax
168 \let\warnfourbytes=\relax \let\warnfivebytes=\relax \let\warnsixbytes=\relax}
169
170 \endinput
171