]>
Commit | Line | Data |
---|---|---|
5850d411 | 1 | diff -uNr xercesc/src/xercesc/util/Makefile.in xercesc/src/xercesc/util.new/Makefile.in |
2 | --- xercesc/src/xercesc/util/Makefile.in Fri Feb 7 01:53:51 2003 | |
3 | +++ xercesc/src/xercesc/util.new/Makefile.in Wed Apr 30 23:50:16 2003 | |
4 | @@ -506,7 +506,8 @@ | |
5 | XMLUTF8Transcoder.hpp \ | |
6 | XMLWin1252Transcoder.hpp \ | |
7 | XML256TableTranscoder.hpp \ | |
8 | - XML88591Transcoder.hpp | |
9 | + XML88591Transcoder.hpp \ | |
10 | + XML88592Transcoder.hpp | |
11 | ||
12 | UTIL/util_CPP_PRIVHEADERS = | |
13 | ||
14 | @@ -573,7 +574,8 @@ | |
15 | XMLUTF8Transcoder.$(TO) \ | |
16 | XMLWin1252Transcoder.$(TO) \ | |
17 | XML256TableTranscoder.$(TO) \ | |
18 | - XML88591Transcoder.$(TO) | |
19 | + XML88591Transcoder.$(TO) \ | |
20 | + XML88592Transcoder.$(TO) | |
21 | ||
22 | ||
23 | all:: includes $(UTIL_CPP_OBJECTS) platforms transcoders \ | |
24 | diff -uNr xercesc/src/xercesc/util/TransService.cpp xercesc/src/xercesc/util.new/TransService.cpp | |
25 | --- xercesc/src/xercesc/util/TransService.cpp Fri Feb 7 01:54:05 2003 | |
26 | +++ xercesc/src/xercesc/util.new/TransService.cpp Wed Apr 30 23:36:53 2003 | |
27 | @@ -64,6 +64,7 @@ | |
28 | #include <xercesc/util/RefHashTableOf.hpp> | |
29 | #include <xercesc/util/RefVectorOf.hpp> | |
30 | #include <xercesc/util/XML88591Transcoder.hpp> | |
31 | +#include <xercesc/util/XML88592Transcoder.hpp> | |
32 | #include <xercesc/util/XMLASCIITranscoder.hpp> | |
33 | #include <xercesc/util/XMLChTranscoder.hpp> | |
34 | #include <xercesc/util/XMLEBCDICTranscoder.hpp> | |
35 | @@ -322,6 +323,22 @@ | |
36 | gMappings->put((void*)XMLUni::fgISO88591EncodingString12, new ENameMapFor<XML88591Transcoder>(XMLUni::fgISO88591EncodingString12)); | |
37 | ||
38 | // | |
39 | + // Add in our mappings for Latin2 | |
40 | + // | |
41 | + gMappings->put((void*)XMLUni::fgISO88592EncodingString, new ENameMapFor<XML88592Transcoder>(XMLUni::fgISO88592EncodingString)); | |
42 | + gMappings->put((void*)XMLUni::fgISO88592EncodingString2, new ENameMapFor<XML88592Transcoder>(XMLUni::fgISO88592EncodingString2)); | |
43 | + gMappings->put((void*)XMLUni::fgISO88592EncodingString3, new ENameMapFor<XML88592Transcoder>(XMLUni::fgISO88592EncodingString3)); | |
44 | + gMappings->put((void*)XMLUni::fgISO88592EncodingString4, new ENameMapFor<XML88592Transcoder>(XMLUni::fgISO88592EncodingString4)); | |
45 | + gMappings->put((void*)XMLUni::fgISO88592EncodingString5, new ENameMapFor<XML88592Transcoder>(XMLUni::fgISO88592EncodingString5)); | |
46 | + gMappings->put((void*)XMLUni::fgISO88592EncodingString6, new ENameMapFor<XML88592Transcoder>(XMLUni::fgISO88592EncodingString6)); | |
47 | + gMappings->put((void*)XMLUni::fgISO88592EncodingString7, new ENameMapFor<XML88592Transcoder>(XMLUni::fgISO88592EncodingString7)); | |
48 | + gMappings->put((void*)XMLUni::fgISO88592EncodingString8, new ENameMapFor<XML88592Transcoder>(XMLUni::fgISO88592EncodingString8)); | |
49 | + gMappings->put((void*)XMLUni::fgISO88592EncodingString9, new ENameMapFor<XML88592Transcoder>(XMLUni::fgISO88592EncodingString9)); | |
50 | + gMappings->put((void*)XMLUni::fgISO88592EncodingString10, new ENameMapFor<XML88592Transcoder>(XMLUni::fgISO88592EncodingString10)); | |
51 | + gMappings->put((void*)XMLUni::fgISO88592EncodingString11, new ENameMapFor<XML88592Transcoder>(XMLUni::fgISO88592EncodingString11)); | |
52 | + gMappings->put((void*)XMLUni::fgISO88592EncodingString12, new ENameMapFor<XML88592Transcoder>(XMLUni::fgISO88592EncodingString12)); | |
53 | + | |
54 | + // | |
55 | // Add in our mappings for UTF-16 and UCS-4, little endian | |
56 | // | |
57 | bool swapped = false; | |
58 | diff -uNr xercesc/src/xercesc/util/XML88592Transcoder.cpp xercesc/src/xercesc/util.new/XML88592Transcoder.cpp | |
59 | --- xercesc/src/xercesc/util/XML88592Transcoder.cpp Thu Jan 1 01:00:00 1970 | |
60 | +++ xercesc/src/xercesc/util.new/XML88592Transcoder.cpp Thu May 1 00:00:20 2003 | |
c06d9f7f | 61 | @@ -0,0 +1,328 @@ |
5850d411 | 62 | +/* |
63 | + * The Apache Software License, Version 1.1 | |
64 | + * | |
65 | + * Copyright (c) 1999-2000 The Apache Software Foundation. All rights | |
66 | + * reserved. | |
67 | + * | |
68 | + * Redistribution and use in source and binary forms, with or without | |
69 | + * modification, are permitted provided that the following conditions | |
70 | + * are met: | |
71 | + * | |
72 | + * 1. Redistributions of source code must retain the above copyright | |
73 | + * notice, this list of conditions and the following disclaimer. | |
74 | + * | |
75 | + * 2. Redistributions in binary form must reproduce the above copyright | |
76 | + * notice, this list of conditions and the following disclaimer in | |
77 | + * the documentation and/or other materials provided with the | |
78 | + * distribution. | |
79 | + * | |
80 | + * 3. The end-user documentation included with the redistribution, | |
81 | + * if any, must include the following acknowledgment: | |
82 | + * "This product includes software developed by the | |
83 | + * Apache Software Foundation (http://www.apache.org/)." | |
84 | + * Alternately, this acknowledgment may appear in the software itself, | |
85 | + * if and wherever such third-party acknowledgments normally appear. | |
86 | + * | |
87 | + * 4. The names "Xerces" and "Apache Software Foundation" must | |
88 | + * not be used to endorse or promote products derived from this | |
89 | + * software without prior written permission. For written | |
90 | + * permission, please contact apache\@apache.org. | |
91 | + * | |
92 | + * 5. Products derived from this software may not be called "Apache", | |
93 | + * nor may "Apache" appear in their name, without prior written | |
94 | + * permission of the Apache Software Foundation. | |
95 | + * | |
96 | + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |
97 | + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
98 | + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
99 | + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |
100 | + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
101 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
102 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |
103 | + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
104 | + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
105 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |
106 | + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
107 | + * SUCH DAMAGE. | |
108 | + * ==================================================================== | |
109 | + * | |
110 | + * This software consists of voluntary contributions made by many | |
111 | + * individuals on behalf of the Apache Software Foundation, and was | |
112 | + * originally based on software copyright (c) 1999, International | |
113 | + * Business Machines, Inc., http://www.ibm.com . For more information | |
114 | + * on the Apache Software Foundation, please see | |
115 | + * <http://www.apache.org/>. | |
116 | + */ | |
117 | + | |
118 | + | |
119 | +// --------------------------------------------------------------------------- | |
120 | +// Includes | |
121 | +// --------------------------------------------------------------------------- | |
122 | +#include <xercesc/util/TranscodingException.hpp> | |
123 | +#include <xercesc/util/XML88592Transcoder.hpp> | |
124 | +#include <xercesc/util/XMLString.hpp> | |
125 | +#include <string.h> | |
126 | + | |
127 | +XERCES_CPP_NAMESPACE_BEGIN | |
128 | + | |
c06d9f7f | 129 | +static const int iso8859_2_utf[] ={ |
130 | +0x000,0x001,0x002,0x003,0x004,0x005,0x006,0x007, | |
131 | +0x008,0x009,0x00a,0x00b,0x00c,0x00d,0x00e,0x00f, | |
132 | +0x010,0x011,0x012,0x013,0x014,0x015,0x016,0x017, | |
133 | +0x018,0x019,0x01a,0x01b,0x01c,0x01d,0x01e,0x01f, | |
134 | +0x020,0x021,0x022,0x023,0x024,0x025,0x026,0x027, | |
135 | +0x028,0x029,0x02a,0x02b,0x02c,0x02d,0x02e,0x02f, | |
136 | +0x030,0x031,0x032,0x033,0x034,0x035,0x036,0x037, | |
137 | +0x038,0x039,0x03a,0x03b,0x03c,0x03d,0x03e,0x03f, | |
138 | +0x040,0x041,0x042,0x043,0x044,0x045,0x046,0x047, | |
139 | +0x048,0x049,0x04a,0x04b,0x04c,0x04d,0x04e,0x04f, | |
140 | +0x050,0x051,0x052,0x053,0x054,0x055,0x056,0x057, | |
141 | +0x058,0x059,0x05a,0x05b,0x05c,0x05d,0x05e,0x05f, | |
142 | +0x060,0x061,0x062,0x063,0x064,0x065,0x066,0x067, | |
143 | +0x068,0x069,0x06a,0x06b,0x06c,0x06d,0x06e,0x06f, | |
144 | +0x070,0x071,0x072,0x073,0x074,0x075,0x076,0x077, | |
145 | +0x078,0x079,0x07a,0x07b,0x07c,0x07d,0x07e,0x07f, | |
146 | +0x080,0x081,0x082,0x083,0x084,0x085,0x086,0x087, | |
147 | +0x088,0x089,0x08a,0x08b,0x08c,0x08d,0x08e,0x08f, | |
148 | +0x090,0x091,0x092,0x093,0x094,0x095,0x096,0x097, | |
149 | +0x098,0x099,0x09a,0x09b,0x09c,0x09d,0x09e,0x09f, | |
150 | +0x0a0,0x104,0x2d8,0x141,0x0a4,0x13d,0x15a,0x0a7, | |
151 | +0x0a8,0x160,0x15e,0x164,0x179,0x0ad,0x17d,0x17b, | |
152 | +0x0b0,0x105,0x2db,0x142,0x0b4,0x13e,0x15b,0x2c7, | |
153 | +0x0b8,0x161,0x15f,0x165,0x17a,0x2dd,0x17e,0x17c, | |
154 | +0x154,0x0c1,0x0c2,0x102,0x0c4,0x139,0x106,0x0c7, | |
155 | +0x10c,0x0c9,0x118,0x0cb,0x11a,0x0cd,0x0ce,0x10e, | |
156 | +0x110,0x143,0x147,0x0d3,0x0d4,0x150,0x0d6,0x0d7, | |
157 | +0x158,0x16e,0x0da,0x170,0x0dc,0x0dd,0x162,0x0df, | |
158 | +0x155,0x0e1,0x0e2,0x103,0x0e4,0x13a,0x107,0x0e7, | |
159 | +0x10d,0x0e9,0x119,0x0eb,0x11b,0x0ed,0x0ee,0x10f, | |
160 | +0x111,0x144,0x148,0x0f3,0x0f4,0x151,0x0f6,0x0f7, | |
161 | +0x159,0x16f,0x0fa,0x171,0x0fc,0x0fd,0x163,0x2d9}; | |
162 | + | |
5850d411 | 163 | +static const char utf_iso8859_2[] ={ |
164 | +0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, | |
165 | +0x08,0x09,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f, | |
166 | +0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, | |
167 | +0x18,0x19,0x1a,0x1b,0x1c,0x1d,0x1e,0x1f, | |
168 | +0x20,0x21,0x22,0x23,0x24,0x25,0x26,0x27, | |
169 | +0x28,0x29,0x2a,0x2b,0x2c,0x2d,0x2e,0x2f, | |
170 | +0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37, | |
171 | +0x38,0x39,0x3a,0x3b,0x3c,0x3d,0x3e,0x3f, | |
172 | +0x40,0x41,0x42,0x43,0x44,0x45,0x46,0x47, | |
173 | +0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f, | |
174 | +0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57, | |
175 | +0x58,0x59,0x5a,0x5b,0x5c,0x5d,0x5e,0x5f, | |
176 | +0x60,0x61,0x62,0x63,0x64,0x65,0x66,0x67, | |
177 | +0x68,0x69,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f, | |
178 | +0x70,0x71,0x72,0x73,0x74,0x75,0x76,0x77, | |
179 | +0x78,0x79,0x7a,0x7b,0x7c,0x7d,0x7e,0x7f, | |
180 | +0x80,0x81,0x82,0x83,0x84,0x85,0x86,0x87, | |
181 | +0x88,0x89,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f, | |
182 | +0x90,0x91,0x92,0x93,0x94,0x95,0x96,0x97, | |
183 | +0x98,0x99,0x9a,0x9b,0x9c,0x9d,0x9e,0x9f, | |
184 | +0xa0,0x00,0x00,0x00,0xa4,0x00,0x00,0xa7, | |
185 | +0xa8,0x00,0x00,0x00,0x00,0xad,0x00,0x00, | |
186 | +0xb0,0x00,0x00,0x00,0xb4,0x00,0x00,0x00, | |
187 | +0xb8,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
188 | +0x00,0xc1,0xc2,0x00,0xc4,0x00,0x00,0xc7, | |
189 | +0x00,0xc9,0x00,0xcb,0x00,0xcd,0xce,0x00, | |
190 | +0x00,0x00,0x00,0xd3,0xd4,0x00,0xd6,0xd7, | |
191 | +0x00,0x00,0xda,0x00,0xdc,0xdd,0x00,0xdf, | |
192 | +0x00,0xe1,0xe2,0x00,0xe4,0x00,0x00,0xe7, | |
193 | +0x00,0xe9,0x00,0xeb,0x00,0xed,0xee,0x00, | |
194 | +0x00,0x00,0x00,0xf3,0xf4,0x00,0xf6,0xf7, | |
195 | +0x00,0x00,0xfa,0x00,0xfc,0xfd,0x00,0x00, | |
196 | +0x00,0x00,0xc3,0xe3,0xa1,0xb1,0xc6,0xe6, | |
197 | +0x00,0x00,0x00,0x00,0xc8,0xe8,0xcf,0xef, | |
198 | +0xd0,0xf0,0x00,0x00,0x00,0x00,0x00,0x00, | |
199 | +0xca,0xea,0xcc,0xec,0x00,0x00,0x00,0x00, | |
200 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
201 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
202 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
203 | +0x00,0xc5,0xe5,0x00,0x00,0xa5,0xb5,0x00, | |
204 | +0x00,0xa3,0xb3,0xd1,0xf1,0x00,0x00,0xd2, | |
205 | +0xf2,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
206 | +0xd5,0xf5,0x00,0x00,0xc0,0xe0,0x00,0x00, | |
207 | +0xd8,0xf8,0xa6,0xb6,0x00,0x00,0xaa,0xba, | |
208 | +0xa9,0xb9,0xde,0xfe,0xab,0xbb,0x00,0x00, | |
209 | +0x00,0x00,0x00,0x00,0x00,0x00,0xd9,0xf9, | |
210 | +0xdb,0xfb,0x00,0x00,0x00,0x00,0x00,0x00, | |
211 | +0x00,0xac,0xbc,0xaf,0xbf,0xae,0xbe,0x00, | |
212 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
213 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
214 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
215 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
216 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
217 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
218 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
219 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
220 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
221 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
222 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
223 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
224 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
225 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
226 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
227 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
228 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
229 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
230 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
231 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
232 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
233 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
234 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
235 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
236 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
237 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
238 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
239 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
240 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
241 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
242 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
243 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
244 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
245 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
246 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
247 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
248 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
249 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
250 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
251 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
252 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xb7, | |
253 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
254 | +0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, | |
255 | +0xa2,0xff,0x00,0xb2,0x00,0xbd}; | |
256 | + | |
257 | +// --------------------------------------------------------------------------- | |
258 | +// XML88592Transcoder: Constructors and Destructor | |
259 | +// --------------------------------------------------------------------------- | |
260 | +XML88592Transcoder::XML88592Transcoder( const XMLCh* const encodingName | |
261 | + , const unsigned int blockSize) : | |
262 | + | |
263 | + XMLTranscoder(encodingName, blockSize) | |
264 | +{ | |
265 | +} | |
266 | + | |
267 | + | |
268 | +XML88592Transcoder::~XML88592Transcoder() | |
269 | +{ | |
270 | +} | |
271 | + | |
272 | + | |
273 | +// --------------------------------------------------------------------------- | |
274 | +// XML88592Transcoder: Implementation of the transcoder API | |
275 | +// --------------------------------------------------------------------------- | |
276 | +unsigned int | |
277 | +XML88592Transcoder::transcodeFrom( const XMLByte* const srcData | |
278 | + , const unsigned int srcCount | |
279 | + , XMLCh* const toFill | |
280 | + , const unsigned int maxChars | |
281 | + , unsigned int& bytesEaten | |
282 | + , unsigned char* const charSizes) | |
283 | +{ | |
284 | + // If debugging, make sure that the block size is legal | |
285 | + #if defined(XERCES_DEBUG) | |
286 | + checkBlockSize(maxChars); | |
287 | + #endif | |
288 | + | |
289 | + // | |
290 | + // Calculate the max chars we can do here. Its the lesser of the | |
291 | + // max output chars and the number of bytes in the source. | |
292 | + // | |
293 | + const unsigned int countToDo = srcCount < maxChars ? srcCount : maxChars; | |
294 | + | |
295 | + // | |
296 | + // Loop through the bytes to do and convert over each byte. Its just | |
297 | + // a cast to the wide char type. | |
298 | + // | |
299 | + const XMLByte* srcPtr = srcData; | |
300 | + XMLCh* destPtr = toFill; | |
301 | + const XMLByte* srcEnd = srcPtr + countToDo; | |
302 | + while (srcPtr < srcEnd) | |
c06d9f7f | 303 | + *destPtr++ = XMLCh(iso8859_2_utf[*srcPtr++]); |
5850d411 | 304 | + |
305 | + // Set the bytes eaten, and set the char size array to the fixed size | |
306 | + bytesEaten = countToDo; | |
307 | + memset(charSizes, 1, countToDo); | |
308 | + | |
309 | + // Return the chars we transcoded | |
310 | + return countToDo; | |
311 | +} | |
312 | + | |
313 | + | |
314 | +unsigned int | |
315 | +XML88592Transcoder::transcodeTo(const XMLCh* const srcData | |
316 | + , const unsigned int srcCount | |
317 | + , XMLByte* const toFill | |
318 | + , const unsigned int maxBytes | |
319 | + , unsigned int& charsEaten | |
320 | + , const UnRepOpts options) | |
321 | +{ | |
322 | + // If debugging, make sure that the block size is legal | |
323 | + #if defined(XERCES_DEBUG) | |
324 | + checkBlockSize(maxBytes); | |
325 | + #endif | |
326 | + | |
327 | + // | |
328 | + // Calculate the max chars we can do here. Its the lesser of the | |
329 | + // max output bytes and the number of chars in the source. | |
330 | + // | |
331 | + const unsigned int countToDo = srcCount < maxBytes ? srcCount : maxBytes; | |
332 | + | |
333 | + // | |
334 | + // Loop through the bytes to do and convert over each byte. Its just | |
335 | + // a downcast of the wide char, checking for unrepresentable chars. | |
336 | + // | |
337 | + const XMLCh* srcPtr = srcData; | |
338 | + const XMLCh* srcEnd = srcPtr + countToDo; | |
339 | + XMLByte* destPtr = toFill; | |
340 | + while (srcPtr < srcEnd) | |
341 | + { | |
342 | + // If its legal, take it and jump back to top | |
343 | + if (*srcPtr == 0) | |
344 | + { | |
345 | + *destPtr++ = XMLByte(*srcPtr++); | |
346 | + continue; | |
347 | + } else if ((*srcPtr<sizeof(utf_iso8859_2)) && (utf_iso8859_2[*srcPtr]!=0)) | |
348 | + { | |
349 | + *destPtr++ = XMLByte(utf_iso8859_2[*srcPtr++]); | |
350 | + continue; | |
351 | + } | |
352 | + | |
353 | + // | |
354 | + // Its not representable so use a replacement char. According to | |
355 | + // the options, either throw or use the replacement. | |
356 | + // | |
357 | + if (options == UnRep_Throw) | |
358 | + { | |
359 | + XMLCh tmpBuf[16]; | |
360 | + XMLString::binToText((unsigned int)*srcPtr, tmpBuf, 16, 16); | |
361 | + ThrowXML2 | |
362 | + ( | |
363 | + TranscodingException | |
364 | + , XMLExcepts::Trans_Unrepresentable | |
365 | + , tmpBuf | |
366 | + , getEncodingName() | |
367 | + ); | |
368 | + } | |
369 | + *destPtr++ = 0x1A; | |
370 | + srcPtr++; | |
371 | + } | |
372 | + | |
373 | + // Set the chars eaten | |
374 | + charsEaten = countToDo; | |
375 | + | |
376 | + // Return the bytes we transcoded | |
377 | + return countToDo; | |
378 | +} | |
379 | + | |
380 | + | |
381 | +bool XML88592Transcoder::canTranscodeTo(const unsigned int toCheck) const | |
382 | +{ | |
383 | + if (toCheck>=sizeof(utf_iso8859_2))return false; | |
384 | + if (utf_iso8859_2[toCheck]!=0)return true; | |
385 | + if (toCheck==0)return true; | |
386 | + return false; | |
387 | +} | |
388 | + | |
389 | +XERCES_CPP_NAMESPACE_END | |
390 | diff -uNr xercesc/src/xercesc/util/XML88592Transcoder.hpp xercesc/src/xercesc/util.new/XML88592Transcoder.hpp | |
391 | --- xercesc/src/xercesc/util/XML88592Transcoder.hpp Thu Jan 1 01:00:00 1970 | |
392 | +++ xercesc/src/xercesc/util.new/XML88592Transcoder.hpp Wed Apr 30 23:41:04 2003 | |
393 | @@ -0,0 +1,127 @@ | |
394 | +/* | |
395 | + * The Apache Software License, Version 1.1 | |
396 | + * | |
397 | + * Copyright (c) 1999-2000 The Apache Software Foundation. All rights | |
398 | + * reserved. | |
399 | + * | |
400 | + * Redistribution and use in source and binary forms, with or without | |
401 | + * modification, are permitted provided that the following conditions | |
402 | + * are met: | |
403 | + * | |
404 | + * 1. Redistributions of source code must retain the above copyright | |
405 | + * notice, this list of conditions and the following disclaimer. | |
406 | + * | |
407 | + * 2. Redistributions in binary form must reproduce the above copyright | |
408 | + * notice, this list of conditions and the following disclaimer in | |
409 | + * the documentation and/or other materials provided with the | |
410 | + * distribution. | |
411 | + * | |
412 | + * 3. The end-user documentation included with the redistribution, | |
413 | + * if any, must include the following acknowledgment: | |
414 | + * "This product includes software developed by the | |
415 | + * Apache Software Foundation (http://www.apache.org/)." | |
416 | + * Alternately, this acknowledgment may appear in the software itself, | |
417 | + * if and wherever such third-party acknowledgments normally appear. | |
418 | + * | |
419 | + * 4. The names "Xerces" and "Apache Software Foundation" must | |
420 | + * not be used to endorse or promote products derived from this | |
421 | + * software without prior written permission. For written | |
422 | + * permission, please contact apache\@apache.org. | |
423 | + * | |
424 | + * 5. Products derived from this software may not be called "Apache", | |
425 | + * nor may "Apache" appear in their name, without prior written | |
426 | + * permission of the Apache Software Foundation. | |
427 | + * | |
428 | + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |
429 | + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
430 | + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |
431 | + * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |
432 | + * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
433 | + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |
434 | + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |
435 | + * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |
436 | + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |
437 | + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |
438 | + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
439 | + * SUCH DAMAGE. | |
440 | + * ==================================================================== | |
441 | + * | |
442 | + * This software consists of voluntary contributions made by many | |
443 | + * individuals on behalf of the Apache Software Foundation, and was | |
444 | + * originally based on software copyright (c) 1999, International | |
445 | + * Business Machines, Inc., http://www.ibm.com . For more information | |
446 | + * on the Apache Software Foundation, please see | |
447 | + * <http://www.apache.org/>. | |
448 | + */ | |
449 | + | |
450 | +#ifndef XML88592TRANSCODER_HPP | |
451 | +#define XML88592TRANSCODER_HPP | |
452 | + | |
453 | +#include <xercesc/util/XercesDefs.hpp> | |
454 | +#include <xercesc/util/TransService.hpp> | |
455 | + | |
456 | +XERCES_CPP_NAMESPACE_BEGIN | |
457 | + | |
458 | +// | |
459 | +// This class provides an implementation of the XMLTranscoder interface | |
460 | +// for a simple 8859-1 transcoder. The parser does some encodings | |
461 | +// intrinsically without depending upon external transcoding services. | |
462 | +// To make everything more orthagonal, we implement these internal | |
463 | +// transcoders using the same transcoder abstraction as the pluggable | |
464 | +// transcoding services do. | |
465 | +// | |
466 | +class XMLUTIL_EXPORT XML88592Transcoder : public XMLTranscoder | |
467 | +{ | |
468 | +public : | |
469 | + // ----------------------------------------------------------------------- | |
470 | + // Public constructors and destructor | |
471 | + // ----------------------------------------------------------------------- | |
472 | + XML88592Transcoder | |
473 | + ( | |
474 | + const XMLCh* const encodingName | |
475 | + , const unsigned int blockSize | |
476 | + ); | |
477 | + | |
478 | + virtual ~XML88592Transcoder(); | |
479 | + | |
480 | + | |
481 | + // ----------------------------------------------------------------------- | |
482 | + // Implementation of the XMLTranscoder interface | |
483 | + // ----------------------------------------------------------------------- | |
484 | + virtual unsigned int transcodeFrom | |
485 | + ( | |
486 | + const XMLByte* const srcData | |
487 | + , const unsigned int srcCount | |
488 | + , XMLCh* const toFill | |
489 | + , const unsigned int maxChars | |
490 | + , unsigned int& bytesEaten | |
491 | + , unsigned char* const charSizes | |
492 | + ); | |
493 | + | |
494 | + virtual unsigned int transcodeTo | |
495 | + ( | |
496 | + const XMLCh* const srcData | |
497 | + , const unsigned int srcCount | |
498 | + , XMLByte* const toFill | |
499 | + , const unsigned int maxBytes | |
500 | + , unsigned int& charsEaten | |
501 | + , const UnRepOpts options | |
502 | + ); | |
503 | + | |
504 | + virtual bool canTranscodeTo | |
505 | + ( | |
506 | + const unsigned int toCheck | |
507 | + ) const; | |
508 | + | |
509 | + | |
510 | +private : | |
511 | + // ----------------------------------------------------------------------- | |
512 | + // Unimplemented constructors and operators | |
513 | + // ----------------------------------------------------------------------- | |
514 | + XML88592Transcoder(const XML88592Transcoder&); | |
515 | + void operator=(const XML88592Transcoder&); | |
516 | +}; | |
517 | + | |
518 | +XERCES_CPP_NAMESPACE_END | |
519 | + | |
520 | +#endif | |
521 | diff -uNr xercesc/src/xercesc/util/XMLUni.cpp xercesc/src/xercesc/util.new/XMLUni.cpp | |
522 | --- xercesc/src/xercesc/util/XMLUni.cpp Fri Feb 7 01:54:07 2003 | |
523 | +++ xercesc/src/xercesc/util.new/XMLUni.cpp Wed Apr 30 23:39:59 2003 | |
524 | @@ -283,6 +283,66 @@ | |
525 | chLatin_L, chDigit_1, chNull | |
526 | }; | |
527 | ||
528 | +const XMLCh XMLUni::fgISO88592EncodingString[] = | |
529 | +{ | |
530 | + chLatin_I, chLatin_S, chLatin_O, chDigit_8, chDigit_8, chDigit_5, chDigit_9, chDash, chDigit_2, chNull | |
531 | +}; | |
532 | + | |
533 | +const XMLCh XMLUni::fgISO88592EncodingString2[] = | |
534 | +{ | |
535 | + chLatin_I, chLatin_S, chLatin_O, chDash, chDigit_8, chDigit_8, chDigit_5, chDigit_9, chDash, chDigit_2, chNull | |
536 | +}; | |
537 | + | |
538 | +const XMLCh XMLUni::fgISO88592EncodingString3[] = | |
539 | +{ | |
540 | + chLatin_I, chLatin_S, chLatin_O, chUnderscore, chDigit_8, chDigit_8, chDigit_5, chDigit_9, chDash, chDigit_2, chNull | |
541 | +}; | |
542 | + | |
543 | +const XMLCh XMLUni::fgISO88592EncodingString4[] = | |
544 | +{ | |
545 | + chLatin_I, chLatin_B, chLatin_M, chDash, chDigit_9, chDigit_1, chDigit_2, chNull | |
546 | +}; | |
547 | + | |
548 | +const XMLCh XMLUni::fgISO88592EncodingString5[] = | |
549 | +{ | |
550 | + chLatin_I, chLatin_B, chLatin_M, chDigit_9, chDigit_1, chDigit_2, chNull | |
551 | +}; | |
552 | + | |
553 | +const XMLCh XMLUni::fgISO88592EncodingString6[] = | |
554 | +{ | |
555 | + chLatin_L, chLatin_A, chLatin_T, chLatin_I, chLatin_N, chDigit_2, chNull | |
556 | +}; | |
557 | + | |
558 | +const XMLCh XMLUni::fgISO88592EncodingString7[] = | |
559 | +{ | |
560 | + chLatin_L, chLatin_A, chLatin_T, chLatin_I, chLatin_N, chDash, chDigit_2, chNull | |
561 | +}; | |
562 | + | |
563 | +const XMLCh XMLUni::fgISO88592EncodingString8[] = | |
564 | +{ | |
565 | + chLatin_L, chLatin_A, chLatin_T, chLatin_I, chLatin_N, chUnderscore, chDigit_2, chNull | |
566 | +}; | |
567 | + | |
568 | +const XMLCh XMLUni::fgISO88592EncodingString9[] = | |
569 | +{ | |
570 | + chLatin_C, chLatin_P, chDigit_9, chDigit_1, chDigit_2, chNull | |
571 | +}; | |
572 | + | |
573 | +const XMLCh XMLUni::fgISO88592EncodingString10[] = | |
574 | +{ | |
575 | + chLatin_C, chLatin_S, chLatin_I, chLatin_S, chLatin_O, chLatin_L, chLatin_A, chLatin_T, chLatin_I, chLatin_N, chDigit_2, chNull | |
576 | +}; | |
577 | + | |
578 | +const XMLCh XMLUni::fgISO88592EncodingString11[] = | |
579 | +{ | |
580 | + chLatin_I, chLatin_S, chLatin_O, chDash, chLatin_I, chLatin_R, chDash, chDigit_2, chDigit_0, chDigit_0, chNull | |
581 | +}; | |
582 | + | |
583 | +const XMLCh XMLUni::fgISO88592EncodingString12[] = | |
584 | +{ | |
585 | + chLatin_L, chDigit_2, chNull | |
586 | +}; | |
587 | + | |
588 | const XMLCh XMLUni::fgLocalHostString[] = | |
589 | { | |
590 | chLatin_l, chLatin_o, chLatin_c, chLatin_a, chLatin_l, chLatin_h, chLatin_o, chLatin_s, chLatin_t, chNull | |
591 | diff -uNr xercesc/src/xercesc/util/XMLUni.hpp xercesc/src/xercesc/util.new/XMLUni.hpp | |
592 | --- xercesc/src/xercesc/util/XMLUni.hpp Fri Feb 7 01:54:07 2003 | |
593 | +++ xercesc/src/xercesc/util.new/XMLUni.hpp Wed Apr 30 23:37:19 2003 | |
594 | @@ -123,6 +123,18 @@ | |
595 | static const XMLCh fgISO88591EncodingString10[]; | |
596 | static const XMLCh fgISO88591EncodingString11[]; | |
597 | static const XMLCh fgISO88591EncodingString12[]; | |
598 | + static const XMLCh fgISO88592EncodingString[]; | |
599 | + static const XMLCh fgISO88592EncodingString2[]; | |
600 | + static const XMLCh fgISO88592EncodingString3[]; | |
601 | + static const XMLCh fgISO88592EncodingString4[]; | |
602 | + static const XMLCh fgISO88592EncodingString5[]; | |
603 | + static const XMLCh fgISO88592EncodingString6[]; | |
604 | + static const XMLCh fgISO88592EncodingString7[]; | |
605 | + static const XMLCh fgISO88592EncodingString8[]; | |
606 | + static const XMLCh fgISO88592EncodingString9[]; | |
607 | + static const XMLCh fgISO88592EncodingString10[]; | |
608 | + static const XMLCh fgISO88592EncodingString11[]; | |
609 | + static const XMLCh fgISO88592EncodingString12[]; | |
610 | static const XMLCh fgLocalHostString[]; | |
611 | static const XMLCh fgNoString[]; | |
612 | static const XMLCh fgNotationString[]; |