1 | /* |
---|
2 | * ---------------------------------------------------------------------- |
---|
3 | * Rappture Library Entity Reference Translation Header |
---|
4 | * |
---|
5 | * Begin Character Entity Translator |
---|
6 | * |
---|
7 | * The next section of code implements routines used to translate |
---|
8 | * character entity references into their corresponding strings. |
---|
9 | * |
---|
10 | * Examples: |
---|
11 | * |
---|
12 | * & "&" |
---|
13 | * < "<" |
---|
14 | * > ">" |
---|
15 | * " " |
---|
16 | * |
---|
17 | * |
---|
18 | * ====================================================================== |
---|
19 | * AUTHOR: Derrick Kearney, Purdue University |
---|
20 | * Copyright (c) 2004-2006 Purdue Research Foundation |
---|
21 | * |
---|
22 | * See the file "license.terms" for information on usage and |
---|
23 | * redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES. |
---|
24 | * |
---|
25 | * Also see below text for additional information on usage and redistribution |
---|
26 | * |
---|
27 | * ====================================================================== |
---|
28 | */ |
---|
29 | /*---------------------------------------------------------------------------- |
---|
30 | | |
---|
31 | | Copyright (c) 2000 Jochen Loewer (loewerj@hotmail.com) |
---|
32 | |----------------------------------------------------------------------------- |
---|
33 | | |
---|
34 | | |
---|
35 | | !! EXPERIMENTAL / pre alpha !! |
---|
36 | | A simple (hopefully fast) HTML parser to build up a DOM structure |
---|
37 | | in memory. |
---|
38 | | Based on xmlsimple.c. |
---|
39 | | !! EXPERIMENTAL / pre alpha !! |
---|
40 | | |
---|
41 | | |
---|
42 | | The contents of this file are subject to the Mozilla Public License |
---|
43 | | Version 1.1 (the "License"); you may not use this file except in |
---|
44 | | compliance with the License. You may obtain a copy of the License at |
---|
45 | | http://www.mozilla.org/MPL/ |
---|
46 | | |
---|
47 | | Software distributed under the License is distributed on an "AS IS" |
---|
48 | | basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
---|
49 | | License for the specific language governing rights and limitations |
---|
50 | | under the License. |
---|
51 | | |
---|
52 | | The Original Code is tDOM. |
---|
53 | | |
---|
54 | | The Initial Developer of the Original Code is Jochen Loewer |
---|
55 | | Portions created by Jochen Loewer are Copyright (C) 1998, 1999 |
---|
56 | | Jochen Loewer. All Rights Reserved. |
---|
57 | | |
---|
58 | | Contributor(s): |
---|
59 | | |
---|
60 | | |
---|
61 | | written by Jochen Loewer |
---|
62 | | October 2000 |
---|
63 | | |
---|
64 | | ------------------------------------------------------------------------ |
---|
65 | | |
---|
66 | | A parser for XML. |
---|
67 | | |
---|
68 | | Copyright (C) 1998 D. Richard Hipp |
---|
69 | | |
---|
70 | | This library is free software; you can redistribute it and/or |
---|
71 | | modify it under the terms of the GNU Library General Public |
---|
72 | | License as published by the Free Software Foundation; either |
---|
73 | | version 2 of the License, or (at your option) any later version. |
---|
74 | | |
---|
75 | | This library is distributed in the hope that it will be useful, |
---|
76 | | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
77 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
78 | | Library General Public License for more details. |
---|
79 | | |
---|
80 | | You should have received a copy of the GNU Library General Public |
---|
81 | | License along with this library; if not, write to the |
---|
82 | | Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
83 | | Boston, MA 02111-1307, USA. |
---|
84 | | |
---|
85 | | Author contact information: |
---|
86 | | drh@acm.org |
---|
87 | | http://www.hwaci.com/drh/ |
---|
88 | | |
---|
89 | \---------------------------------------------------------------------------*/ |
---|
90 | |
---|
91 | #include "RpEntityRef.h" |
---|
92 | #include <cctype> |
---|
93 | #include <cstring> |
---|
94 | |
---|
95 | int RpEntityRef::bErNeedsInit = 1; |
---|
96 | Er* RpEntityRef::apErHash[ER_HASH_SIZE]; |
---|
97 | |
---|
98 | /*---------------------------------------------------------------------------- |
---|
99 | | ErHash -- |
---|
100 | | |
---|
101 | | Hash an entity reference name. The value returned is an |
---|
102 | | integer between 0 and Er_HASH_SIZE-1, inclusive. |
---|
103 | | |
---|
104 | \---------------------------------------------------------------------------*/ |
---|
105 | int |
---|
106 | RpEntityRef::ErHash( const char *zName) |
---|
107 | { |
---|
108 | int h = 0; /* The hash value to be returned */ |
---|
109 | char c; /* The next character in the name being hashed */ |
---|
110 | |
---|
111 | while( (c=*zName)!=0 ){ |
---|
112 | h = h<<5 ^ h ^ c; |
---|
113 | zName++; |
---|
114 | } |
---|
115 | if( h<0 ) h = -h; |
---|
116 | return h % ER_HASH_SIZE; |
---|
117 | |
---|
118 | } /* ErHash */ |
---|
119 | |
---|
120 | |
---|
121 | |
---|
122 | |
---|
123 | /*---------------------------------------------------------------------------- |
---|
124 | | ErInit -- |
---|
125 | | |
---|
126 | | Initialize the entity reference hash table |
---|
127 | | |
---|
128 | \---------------------------------------------------------------------------*/ |
---|
129 | void |
---|
130 | RpEntityRef::ErInit (void) |
---|
131 | { |
---|
132 | int i; /* For looping thru the list of entity references */ |
---|
133 | int h; /* The hash on a entity */ |
---|
134 | |
---|
135 | for(i=0; ((unsigned)i)<sizeof(er_sequences)/sizeof(er_sequences[0]); i++){ |
---|
136 | // hash the reference name |
---|
137 | h = ErHash(er_sequences[i].zName); |
---|
138 | er_sequences[i].pNextForw = apErHash[h]; |
---|
139 | apErHash[h] = &er_sequences[i]; |
---|
140 | } |
---|
141 | |
---|
142 | } /* ErInit */ |
---|
143 | |
---|
144 | |
---|
145 | /*---------------------------------------------------------------------------- |
---|
146 | | TranslateEntityRefs -- |
---|
147 | | |
---|
148 | | Translate entity references and character references in the string |
---|
149 | | "z". "z" is overwritten with the translated sequence. |
---|
150 | | |
---|
151 | | Unrecognized entity references are unaltered. |
---|
152 | | |
---|
153 | | Example: |
---|
154 | | |
---|
155 | | input = "AT&T > MCI" |
---|
156 | | output = "AT&T > MCI" |
---|
157 | | |
---|
158 | | transDir - translation direction |
---|
159 | | FORWARD_TRANS is from < to < |
---|
160 | | BACKWARD_TRANS is from < to < |
---|
161 | | |
---|
162 | \---------------------------------------------------------------------------*/ |
---|
163 | void |
---|
164 | RpEntityRef::TranslateEntityRefs (char *z, int *newLen) |
---|
165 | { |
---|
166 | int from; /* Read characters from this position in z[] */ |
---|
167 | int to; /* Write characters into this position in z[] */ |
---|
168 | int h; /* A hash on the entity reference */ |
---|
169 | char *zVal; /* The substituted value */ |
---|
170 | Er *p; /* For looping down the entity reference collision chain */ |
---|
171 | int value; |
---|
172 | |
---|
173 | from = to = 0; |
---|
174 | |
---|
175 | if (bErNeedsInit) { |
---|
176 | if (bErNeedsInit) { |
---|
177 | ErInit(); |
---|
178 | bErNeedsInit = 0; |
---|
179 | } |
---|
180 | } |
---|
181 | |
---|
182 | while (z[from]) { |
---|
183 | if (z[from]=='&') { |
---|
184 | int i = from+1; |
---|
185 | int c; |
---|
186 | |
---|
187 | if (z[i] == '#') { |
---|
188 | /*--------------------------------------------- |
---|
189 | | convert character reference |
---|
190 | \--------------------------------------------*/ |
---|
191 | value = 0; |
---|
192 | if (z[++i] == 'x') { |
---|
193 | i++; |
---|
194 | while ((c=z[i]) && (c!=';')) { |
---|
195 | value = value * 16; |
---|
196 | if ((c>='0') && (c<='9')) { |
---|
197 | value += c-'0'; |
---|
198 | } else |
---|
199 | if ((c>='A') && (c<='F')) { |
---|
200 | value += c-'A' + 10; |
---|
201 | } else |
---|
202 | if ((c>='a') && (c<='f')) { |
---|
203 | value += c-'a' + 10; |
---|
204 | } else { |
---|
205 | /* error */ |
---|
206 | } |
---|
207 | i++; |
---|
208 | } |
---|
209 | } else { |
---|
210 | while ((c=z[i]) && (c!=';')) { |
---|
211 | value = value * 10; |
---|
212 | if ((c>='0') && (c<='9')) { |
---|
213 | value += c-'0'; |
---|
214 | } else { |
---|
215 | /* error */ |
---|
216 | } |
---|
217 | i++; |
---|
218 | } |
---|
219 | } |
---|
220 | if (z[i]!=';') { |
---|
221 | /* error */ |
---|
222 | } |
---|
223 | from = i+1; |
---|
224 | #if RpER8Bits |
---|
225 | z[to++] = value; |
---|
226 | #else |
---|
227 | if (value < 0x80) { |
---|
228 | z[to++] = value; |
---|
229 | } else if (value <= 0x7FF) { |
---|
230 | z[to++] = (char) ((value >> 6) | 0xC0); |
---|
231 | z[to++] = (char) ((value | 0x80) & 0xBF); |
---|
232 | } else if (value <= 0xFFFF) { |
---|
233 | z[to++] = (char) ((value >> 12) | 0xE0); |
---|
234 | z[to++] = (char) (((value >> 6) | 0x80) & 0xBF); |
---|
235 | z[to++] = (char) ((value | 0x80) & 0xBF); |
---|
236 | } else { |
---|
237 | /* error */ |
---|
238 | } |
---|
239 | #endif |
---|
240 | } else { |
---|
241 | while (z[i] && isalpha(z[i])) { |
---|
242 | i++; |
---|
243 | } |
---|
244 | c = z[i]; |
---|
245 | z[i] = 0; |
---|
246 | h = ErHash(&z[from+1]); |
---|
247 | p = apErHash[h]; |
---|
248 | while (p && strncmp(p->zName,&z[from+1],strlen(p->zName))!=0 ) { |
---|
249 | p = p->pNextForw; |
---|
250 | } |
---|
251 | z[i] = c; |
---|
252 | if (p) { |
---|
253 | zVal = p->zValue; |
---|
254 | while (*zVal) { |
---|
255 | z[to++] = *(zVal++); |
---|
256 | } |
---|
257 | from = i; |
---|
258 | if (c==';') from++; |
---|
259 | } else { |
---|
260 | z[to++] = z[from++]; |
---|
261 | } |
---|
262 | } |
---|
263 | } else { |
---|
264 | z[to++] = z[from++]; |
---|
265 | } |
---|
266 | } |
---|
267 | z[to] = 0; |
---|
268 | *newLen = to; |
---|
269 | } |
---|
270 | /*---------------------------------------------------------------------------- |
---|
271 | | End Of Character Entity Translator |
---|
272 | \---------------------------------------------------------------------------*/ |
---|
273 | |
---|
274 | |
---|
275 | void |
---|
276 | RpEntityRef::appendEscaped ( |
---|
277 | std::string& value, |
---|
278 | std::string& retStr |
---|
279 | // int htmlEntities, |
---|
280 | ) |
---|
281 | { |
---|
282 | // #define AP(c) *b++ = c; |
---|
283 | // #define AE(s) pc1 = s; while(*pc1) *b++ = *pc1++; |
---|
284 | unsigned int pos = 0; |
---|
285 | |
---|
286 | retStr = ""; |
---|
287 | |
---|
288 | if (!value.empty()) { |
---|
289 | |
---|
290 | while (pos < value.length()) { |
---|
291 | if (value.at(pos) == '"') { |
---|
292 | retStr += """; |
---|
293 | } |
---|
294 | else if (value.at(pos) == '&') { |
---|
295 | retStr += "&"; |
---|
296 | } |
---|
297 | else if (value.at(pos) == '<') { |
---|
298 | retStr += "<"; |
---|
299 | } |
---|
300 | else if (value.at(pos) == '>') { |
---|
301 | retStr += ">"; |
---|
302 | } |
---|
303 | /* |
---|
304 | else if (value.at(pos) == '\n') { |
---|
305 | retStr += "
"; |
---|
306 | } |
---|
307 | */ |
---|
308 | else |
---|
309 | { |
---|
310 | retStr += value.at(pos); |
---|
311 | |
---|
312 | // this deals with all of the html entities |
---|
313 | /* |
---|
314 | charDone = 0; |
---|
315 | if (htmlEntities) { |
---|
316 | charDone = 1; |
---|
317 | #if RpER8Bits |
---|
318 | switch ((unsigned int)*pc) |
---|
319 | #else··········· |
---|
320 | Tcl_UtfToUniChar(pc, &uniChar); |
---|
321 | switch (uniChar)· |
---|
322 | #endif |
---|
323 | { |
---|
324 | case 0240: AE(" "); break;····· |
---|
325 | case 0241: AE("¡"); break;···· |
---|
326 | case 0242: AE("¢"); break;····· |
---|
327 | case 0243: AE("£"); break;···· |
---|
328 | case 0244: AE("¤"); break;··· |
---|
329 | case 0245: AE("¥"); break;······ |
---|
330 | case 0246: AE("¦"); break;··· |
---|
331 | case 0247: AE("§"); break;····· |
---|
332 | case 0250: AE("¨"); break;······ |
---|
333 | case 0251: AE("©"); break;····· |
---|
334 | case 0252: AE("ª"); break;····· |
---|
335 | case 0253: AE("«"); break;···· |
---|
336 | case 0254: AE("¬"); break;······ |
---|
337 | case 0255: AE("­"); break;······ |
---|
338 | case 0256: AE("®"); break;······ |
---|
339 | case 0257: AE("¯"); break;····· |
---|
340 | case 0260: AE("°"); break;······ |
---|
341 | case 0261: AE("±"); break;··· |
---|
342 | case 0262: AE("²"); break;····· |
---|
343 | case 0263: AE("³"); break;····· |
---|
344 | case 0264: AE("´"); break;···· |
---|
345 | case 0265: AE("µ"); break;···· |
---|
346 | case 0266: AE("¶"); break;····· |
---|
347 | case 0267: AE("·"); break;··· |
---|
348 | case 0270: AE("¸"); break;···· |
---|
349 | case 0271: AE("¹"); break;····· |
---|
350 | case 0272: AE("º"); break;····· |
---|
351 | case 0273: AE("»"); break;···· |
---|
352 | case 0274: AE("¼"); break;··· |
---|
353 | case 0275: AE("½"); break;··· |
---|
354 | case 0276: AE("¾"); break;··· |
---|
355 | case 0277: AE("¿"); break;··· |
---|
356 | case 0300: AE("À"); break;··· |
---|
357 | case 0301: AE("Á"); break;··· |
---|
358 | case 0302: AE("Â"); break;···· |
---|
359 | case 0303: AE("Ã"); break;··· |
---|
360 | case 0304: AE("Ä"); break;····· |
---|
361 | case 0305: AE("Å"); break;···· |
---|
362 | case 0306: AE("Æ"); break;···· |
---|
363 | case 0307: AE("Ç"); break;··· |
---|
364 | case 0310: AE("È"); break;··· |
---|
365 | case 0311: AE("É"); break;··· |
---|
366 | case 0312: AE("Ê"); break;···· |
---|
367 | case 0313: AE("Ë"); break;····· |
---|
368 | case 0314: AE("Ì"); break;··· |
---|
369 | case 0315: AE("Í"); break;··· |
---|
370 | case 0316: AE("Î"); break;···· |
---|
371 | case 0317: AE("Ï"); break;····· |
---|
372 | case 0320: AE("Ð"); break;······ |
---|
373 | case 0321: AE("Ñ"); break;··· |
---|
374 | case 0322: AE("Ò"); break;··· |
---|
375 | case 0323: AE("Ó"); break;··· |
---|
376 | case 0324: AE("Ô"); break;···· |
---|
377 | case 0325: AE("Õ"); break;··· |
---|
378 | case 0326: AE("Ö"); break;····· |
---|
379 | case 0327: AE("×"); break;···· |
---|
380 | case 0330: AE("Ø"); break;··· |
---|
381 | case 0331: AE("Ù"); break;··· |
---|
382 | case 0332: AE("Ú"); break;··· |
---|
383 | case 0333: AE("Û"); break;···· |
---|
384 | case 0334: AE("Ü"); break;····· |
---|
385 | case 0335: AE("Ý"); break;··· |
---|
386 | case 0336: AE("Þ"); break;···· |
---|
387 | case 0337: AE("ß"); break;···· |
---|
388 | case 0340: AE("à"); break;··· |
---|
389 | case 0341: AE("á"); break;··· |
---|
390 | case 0342: AE("â"); break;···· |
---|
391 | case 0343: AE("ã"); break;··· |
---|
392 | case 0344: AE("ä"); break;····· |
---|
393 | case 0345: AE("å"); break;···· |
---|
394 | case 0346: AE("æ"); break;···· |
---|
395 | case 0347: AE("ç"); break;··· |
---|
396 | case 0350: AE("è"); break;··· |
---|
397 | case 0351: AE("é"); break;··· |
---|
398 | case 0352: AE("ê"); break;···· |
---|
399 | case 0353: AE("ë"); break;····· |
---|
400 | case 0354: AE("ì"); break;··· |
---|
401 | case 0355: AE("í"); break;··· |
---|
402 | case 0356: AE("î"); break;···· |
---|
403 | case 0357: AE("ï"); break;····· |
---|
404 | case 0360: AE("ð"); break;······ |
---|
405 | case 0361: AE("ñ"); break;··· |
---|
406 | case 0362: AE("ò"); break;··· |
---|
407 | case 0363: AE("ó"); break;··· |
---|
408 | case 0364: AE("ô"); break;···· |
---|
409 | case 0365: AE("õ"); break;··· |
---|
410 | case 0366: AE("ö"); break;····· |
---|
411 | case 0367: AE("÷"); break;··· |
---|
412 | case 0370: AE("ø"); break;··· |
---|
413 | case 0371: AE("ù"); break;··· |
---|
414 | case 0372: AE("ú"); break;··· |
---|
415 | case 0373: AE("û"); break;···· |
---|
416 | case 0374: AE("ü"); break;····· |
---|
417 | case 0375: AE("ý"); break;··· |
---|
418 | case 0376: AE("þ"); break;···· |
---|
419 | case 0377: AE("ÿ"); break;····· |
---|
420 | #if !TclOnly8Bits |
---|
421 | // "Special" chars, according to XHTML xhtml-special.ent |
---|
422 | case 338: AE("Œ"); break; |
---|
423 | case 339: AE("œ"); break; |
---|
424 | case 352: AE("Š"); break; |
---|
425 | case 353: AE("š"); break; |
---|
426 | case 376: AE("Ÿ"); break; |
---|
427 | case 710: AE("ˆ"); break; |
---|
428 | case 732: AE("˜"); break; |
---|
429 | case 8194: AE(" "); break; |
---|
430 | case 8195: AE(" "); break; |
---|
431 | case 8201: AE(" "); break; |
---|
432 | case 8204: AE("‌"); break; |
---|
433 | case 8205: AE("‍"); break; |
---|
434 | case 8206: AE("‎"); break; |
---|
435 | case 8207: AE("‏"); break; |
---|
436 | case 8211: AE("–"); break; |
---|
437 | case 8212: AE("—"); break; |
---|
438 | case 8216: AE("‘"); break; |
---|
439 | case 8217: AE("’"); break; |
---|
440 | case 8218: AE("‚"); break; |
---|
441 | case 8220: AE("“"); break; |
---|
442 | case 8221: AE("”"); break; |
---|
443 | case 8222: AE("„"); break; |
---|
444 | case 8224: AE("†"); break; |
---|
445 | case 8225: AE("‡"); break; |
---|
446 | case 8240: AE("‰"); break; |
---|
447 | case 8249: AE("‹"); break; |
---|
448 | case 8250: AE("›"); break; |
---|
449 | case 8364: AE("€"); break; |
---|
450 | // "Symbol" chars, according to XHTML xhtml-symbol.ent |
---|
451 | case 402: AE("ƒ"); break;····· |
---|
452 | case 913: AE("Α"); break;···· |
---|
453 | case 914: AE("Β"); break;····· |
---|
454 | case 915: AE("Γ"); break;···· |
---|
455 | case 916: AE("Δ"); break;···· |
---|
456 | case 917: AE("Ε"); break;·· |
---|
457 | case 918: AE("Ζ"); break;····· |
---|
458 | case 919: AE("Η"); break;······ |
---|
459 | case 920: AE("Θ"); break;···· |
---|
460 | case 921: AE("Ι"); break;····· |
---|
461 | case 922: AE("Κ"); break;···· |
---|
462 | case 923: AE("Λ"); break;··· |
---|
463 | case 924: AE("Μ"); break;······· |
---|
464 | case 925: AE("Ν"); break;······· |
---|
465 | case 926: AE("Ξ"); break;······· |
---|
466 | case 927: AE("Ο"); break;·· |
---|
467 | case 928: AE("Π"); break;······· |
---|
468 | case 929: AE("Ρ"); break;······ |
---|
469 | case 931: AE("Σ"); break;···· |
---|
470 | case 932: AE("Τ"); break;······ |
---|
471 | case 933: AE("Υ"); break;·· |
---|
472 | case 934: AE("Φ"); break;······ |
---|
473 | case 935: AE("Χ"); break;······ |
---|
474 | case 936: AE("Ψ"); break;······ |
---|
475 | case 937: AE("Ω"); break;···· |
---|
476 | case 945: AE("α"); break;···· |
---|
477 | case 946: AE("β"); break;····· |
---|
478 | case 947: AE("γ"); break;···· |
---|
479 | case 948: AE("δ"); break;···· |
---|
480 | case 949: AE("ε"); break;·· |
---|
481 | case 950: AE("ζ"); break;····· |
---|
482 | case 951: AE("η"); break;······ |
---|
483 | case 952: AE("θ"); break;···· |
---|
484 | case 953: AE("ι"); break;····· |
---|
485 | case 954: AE("κ"); break;···· |
---|
486 | case 955: AE("λ"); break;··· |
---|
487 | case 956: AE("μ"); break;······· |
---|
488 | case 957: AE("ν"); break;······· |
---|
489 | case 958: AE("ξ"); break;······· |
---|
490 | case 959: AE("ο"); break;·· |
---|
491 | case 960: AE("π"); break;······· |
---|
492 | case 961: AE("ρ"); break;······ |
---|
493 | case 962: AE("ς"); break;··· |
---|
494 | case 963: AE("σ"); break;···· |
---|
495 | case 964: AE("τ"); break;······ |
---|
496 | case 965: AE("υ"); break;·· |
---|
497 | case 966: AE("φ"); break;······ |
---|
498 | case 967: AE("χ"); break;······ |
---|
499 | case 968: AE("ψ"); break;······ |
---|
500 | case 969: AE("ω"); break;···· |
---|
501 | case 977: AE("ϑ");break;· |
---|
502 | case 978: AE("ϒ"); break;···· |
---|
503 | case 982: AE("ϖ"); break;······ |
---|
504 | case 8226: AE("•"); break;····· |
---|
505 | case 8230: AE("…"); break;··· |
---|
506 | case 8242: AE("′"); break;···· |
---|
507 | case 8243: AE("″"); break;···· |
---|
508 | case 8254: AE("‾"); break;···· |
---|
509 | case 8260: AE("⁄"); break;···· |
---|
510 | case 8472: AE("℘"); break;··· |
---|
511 | case 8465: AE("ℑ"); break;···· |
---|
512 | case 8476: AE("ℜ"); break;····· |
---|
513 | case 8482: AE("™"); break;···· |
---|
514 | case 8501: AE("ℵ"); break;·· |
---|
515 | case 8592: AE("←"); break;····· |
---|
516 | case 8593: AE("↑"); break;····· |
---|
517 | case 8594: AE("→"); break;····· |
---|
518 | case 8595: AE("↓"); break;····· |
---|
519 | case 8596: AE("↔"); break;····· |
---|
520 | case 8629: AE("↵"); break;···· |
---|
521 | case 8656: AE("⇐"); break;····· |
---|
522 | case 8657: AE("⇑"); break;····· |
---|
523 | case 8658: AE("⇒"); break;····· |
---|
524 | case 8659: AE("⇓"); break;····· |
---|
525 | case 8660: AE("⇔"); break;····· |
---|
526 | case 8704: AE("∀"); break;··· |
---|
527 | case 8706: AE("∂"); break;····· |
---|
528 | case 8707: AE("∃"); break;···· |
---|
529 | case 8709: AE("∅"); break;···· |
---|
530 | case 8711: AE("∇"); break;···· |
---|
531 | case 8712: AE("∈"); break;····· |
---|
532 | case 8713: AE("∉"); break;···· |
---|
533 | case 8715: AE("∋"); break;······· |
---|
534 | case 8719: AE("∏"); break;····· |
---|
535 | case 8721: AE("∑"); break;······ |
---|
536 | case 8722: AE("−"); break;···· |
---|
537 | case 8727: AE("∗"); break;··· |
---|
538 | case 8730: AE("√"); break;···· |
---|
539 | case 8733: AE("∝"); break;····· |
---|
540 | case 8734: AE("∞"); break;···· |
---|
541 | case 8736: AE("∠"); break;······ |
---|
542 | case 8743: AE("∧"); break;······ |
---|
543 | case 8744: AE("∨"); break;······· |
---|
544 | case 8745: AE("∩"); break;······ |
---|
545 | case 8746: AE("∪"); break;······ |
---|
546 | case 8747: AE("∫"); break;······ |
---|
547 | case 8756: AE("∴"); break;··· |
---|
548 | case 8764: AE("∼"); break;······ |
---|
549 | case 8773: AE("≅"); break;····· |
---|
550 | case 8776: AE("≈"); break;···· |
---|
551 | case 8800: AE("≠"); break;······· |
---|
552 | case 8801: AE("≡"); break;···· |
---|
553 | case 8804: AE("≤"); break;······· |
---|
554 | case 8805: AE("≥"); break;······· |
---|
555 | case 8834: AE("⊂"); break;······ |
---|
556 | case 8835: AE("⊃"); break;······ |
---|
557 | case 8836: AE("⊄"); break;····· |
---|
558 | case 8838: AE("⊆"); break;····· |
---|
559 | case 8839: AE("⊇"); break;····· |
---|
560 | case 8853: AE("⊕"); break;···· |
---|
561 | case 8855: AE("⊗"); break;··· |
---|
562 | case 8869: AE("⊥"); break;····· |
---|
563 | case 8901: AE("⋅"); break;····· |
---|
564 | case 8968: AE("⌈"); break;···· |
---|
565 | case 8969: AE("⌉"); break;···· |
---|
566 | case 8970: AE("⌊"); break;··· |
---|
567 | case 8971: AE("⌋"); break;··· |
---|
568 | case 9001: AE("⟨"); break;····· |
---|
569 | case 9002: AE("⟩"); break;····· |
---|
570 | case 9674: AE("◊"); break;······ |
---|
571 | case 9824: AE("♠"); break;··· |
---|
572 | case 9827: AE("♣"); break;···· |
---|
573 | case 9829: AE("♥"); break;··· |
---|
574 | case 9830: AE("♦"); break;···· |
---|
575 | #endif···················· |
---|
576 | default: charDone = 0;· |
---|
577 | } |
---|
578 | #if !TclOnly8Bits |
---|
579 | if (charDone) { |
---|
580 | clen = UTF8_CHAR_LEN(*pc); |
---|
581 | pc += (clen - 1); |
---|
582 | } |
---|
583 | #endif |
---|
584 | } |
---|
585 | #if TclOnly8Bits |
---|
586 | if (!charDone) { |
---|
587 | if (escapeNonASCII && ((unsigned char)*pc > 127)) { |
---|
588 | AP('&') AP('#') |
---|
589 | sprintf(charRef, "%d", (unsigned char)*pc); |
---|
590 | for (i = 0; i < 3; i++) { |
---|
591 | AP(charRef[i]); |
---|
592 | } |
---|
593 | AP(';') |
---|
594 | } else { |
---|
595 | AP(*pc); |
---|
596 | } |
---|
597 | } |
---|
598 | #else |
---|
599 | if (!charDone) { |
---|
600 | if ((unsigned char)*pc > 127) { |
---|
601 | clen = UTF8_CHAR_LEN(*pc); |
---|
602 | if (!clen) { |
---|
603 | domPanic("tcldom_AppendEscaped: can only handle " |
---|
604 | "UTF-8 chars up to 3 bytes length"); |
---|
605 | } |
---|
606 | if (escapeNonASCII) { |
---|
607 | Tcl_UtfToUniChar(pc, &uniChar); |
---|
608 | AP('&') AP('#') |
---|
609 | sprintf(charRef, "%d", uniChar); |
---|
610 | for (i = 0; i < strlen(charRef); i++) { |
---|
611 | AP(charRef[i]); |
---|
612 | } |
---|
613 | AP(';') |
---|
614 | pc += (clen - 1); |
---|
615 | } else { |
---|
616 | for (i = 0; i < clen; i++) { |
---|
617 | AP(*pc); |
---|
618 | pc++; |
---|
619 | } |
---|
620 | pc--; |
---|
621 | } |
---|
622 | } else { |
---|
623 | AP(*pc); |
---|
624 | } |
---|
625 | } |
---|
626 | #endif |
---|
627 | */ |
---|
628 | } |
---|
629 | pos++; |
---|
630 | } |
---|
631 | } |
---|
632 | else { |
---|
633 | retStr = value; |
---|
634 | } |
---|
635 | } |
---|
636 | |
---|