Debian Codegraph @

mcs/class/I18N/Other/CP874.cs

raw symbols SCIP
1 /*
2 * CP874.cs - Thai (Windows) code page.
3 *
4 * Copyright (c) 2002 Southern Storm Software, Pty Ltd
5 *
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 // Generated from "ibm-874.ucm".
26
27 // WARNING: Modifying this file directly might be a bad idea.
28 // You should edit the code generator tools/ucm2cp.c instead for your changes
29 // to appear in all relevant classes.
30 namespace I18N.Other
31 {
32
33 using System;
34 using System.Text;
35 using I18N.Common;
36
37 [Serializable]
38 public class CP874 : ByteEncoding
39 {
40 public CP874()
41 : base(874, ToChars, "Thai (Windows)",
42 "windows-874", "windows-874", "windows-874",
43 true, true, true, true, 874)
44 {}
45
46 private static readonly char[] ToChars = {
47 '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005',
48 '\u0006', '\u0007', '\u0008', '\u0009', '\u000A', '\u000B',
49 '\u000C', '\u000D', '\u000E', '\u000F', '\u0010', '\u0011',
50 '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
51 '\u0018', '\u0019', '\u001C', '\u001B', '\u007F', '\u001D',
52 '\u001E', '\u001F', '\u0020', '\u0021', '\u0022', '\u0023',
53 '\u0024', '\u0025', '\u0026', '\u0027', '\u0028', '\u0029',
54 '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
55 '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035',
56 '\u0036', '\u0037', '\u0038', '\u0039', '\u003A', '\u003B',
57 '\u003C', '\u003D', '\u003E', '\u003F', '\u0040', '\u0041',
58 '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
59 '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D',
60 '\u004E', '\u004F', '\u0050', '\u0051', '\u0052', '\u0053',
61 '\u0054', '\u0055', '\u0056', '\u0057', '\u0058', '\u0059',
62 '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
63 '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065',
64 '\u0066', '\u0067', '\u0068', '\u0069', '\u006A', '\u006B',
65 '\u006C', '\u006D', '\u006E', '\u006F', '\u0070', '\u0071',
66 '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
67 '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D',
68 '\u007E', '\u001A', '\u003F', '\u003F', '\u003F', '\u003F',
69 '\u003F', '\u003F', '\u003F', '\u003F', '\u003F', '\u003F',
70 '\u003F', '\u003F', '\u003F', '\u003F', '\u003F', '\u003F',
71 '\u003F', '\u003F', '\u003F', '\u003F', '\u003F', '\u003F',
72 '\u003F', '\u003F', '\u003F', '\u003F', '\u003F', '\u003F',
73 '\u003F', '\u003F', '\u003F', '\u003F', '\u0E48', '\u0E01',
74 '\u0E02', '\u0E03', '\u0E04', '\u0E05', '\u0E06', '\u0E07',
75 '\u0E08', '\u0E09', '\u0E0A', '\u0E0B', '\u0E0C', '\u0E0D',
76 '\u0E0E', '\u0E0F', '\u0E10', '\u0E11', '\u0E12', '\u0E13',
77 '\u0E14', '\u0E15', '\u0E16', '\u0E17', '\u0E18', '\u0E19',
78 '\u0E1A', '\u0E1B', '\u0E1C', '\u0E1D', '\u0E1E', '\u0E1F',
79 '\u0E20', '\u0E21', '\u0E22', '\u0E23', '\u0E24', '\u0E25',
80 '\u0E26', '\u0E27', '\u0E28', '\u0E29', '\u0E2A', '\u0E2B',
81 '\u0E2C', '\u0E2D', '\u0E2E', '\u0E2F', '\u0E30', '\u0E31',
82 '\u0E32', '\u0E33', '\u0E34', '\u0E35', '\u0E36', '\u0E37',
83 '\u0E38', '\u0E39', '\u0E3A', '\u0E49', '\u0E4A', '\u0E4B',
84 '\u0E4C', '\u0E3F', '\u0E40', '\u0E41', '\u0E42', '\u0E43',
85 '\u0E44', '\u0E45', '\u0E46', '\u0E47', '\u0E48', '\u0E49',
86 '\u0E4A', '\u0E4B', '\u0E4C', '\u0E4D', '\u0E4E', '\u0E4F',
87 '\u0E50', '\u0E51', '\u0E52', '\u0E53', '\u0E54', '\u0E55',
88 '\u0E56', '\u0E57', '\u0E58', '\u0E59', '\u0E5A', '\u0E5B',
89 '\u00A2', '\u00AC', '\u00A6', '\u00A0',
90 };
91
92 // Get the number of bytes needed to encode a character buffer.
93 public unsafe override int GetByteCountImpl (char* chars, int count)
94 {
95 if (this.EncoderFallback != null) {
96 //Calculate byte count by actually doing encoding and discarding the data.
97 return GetBytesImpl(chars, count, null, 0);
98 }
99 else
100 {
101 return count;
102 }
103 }
104
105 // Get the number of bytes needed to encode a character buffer.
106 public override int GetByteCount (String s)
107 {
108 if (this.EncoderFallback != null)
109 {
110 //Calculate byte count by actually doing encoding and discarding the data.
111 unsafe
112 {
113 fixed (char *s_ptr = s)
114 {
115 return GetBytesImpl(s_ptr, s.Length, null, 0);
116 }
117 }
118 }
119 else
120 {
121 //byte count equals character count because no EncoderFallback set
122 return s.Length;
123 }
124 }
125
126 //ToBytes is just an alias for GetBytesImpl, but doesn't return byte count
127 protected unsafe override void ToBytes(char* chars, int charCount,
128 byte* bytes, int byteCount)
129 {
130 //Calling ToBytes with null destination buffer doesn't make any sense
131 if (bytes == null)
132 throw new ArgumentNullException("bytes");
133 GetBytesImpl(chars, charCount, bytes, byteCount);
134 }
135
136 public unsafe override int GetBytesImpl (char* chars, int charCount,
137 byte* bytes, int byteCount)
138 {
139 int ch;
140 int charIndex = 0;
141 int byteIndex = 0;
142 EncoderFallbackBuffer buffer = null;
143 while (charCount > 0)
144 {
145 ch = (int)(chars[charIndex]);
146 if(ch >= 26) switch(ch)
147 {
148 case 0x001B:
149 case 0x001D:
150 case 0x001E:
151 case 0x001F:
152 case 0x0020:
153 case 0x0021:
154 case 0x0022:
155 case 0x0023:
156 case 0x0024:
157 case 0x0025:
158 case 0x0026:
159 case 0x0027:
160 case 0x0028:
161 case 0x0029:
162 case 0x002A:
163 case 0x002B:
164 case 0x002C:
165 case 0x002D:
166 case 0x002E:
167 case 0x002F:
168 case 0x0030:
169 case 0x0031:
170 case 0x0032:
171 case 0x0033:
172 case 0x0034:
173 case 0x0035:
174 case 0x0036:
175 case 0x0037:
176 case 0x0038:
177 case 0x0039:
178 case 0x003A:
179 case 0x003B:
180 case 0x003C:
181 case 0x003D:
182 case 0x003E:
183 case 0x003F:
184 case 0x0040:
185 case 0x0041:
186 case 0x0042:
187 case 0x0043:
188 case 0x0044:
189 case 0x0045:
190 case 0x0046:
191 case 0x0047:
192 case 0x0048:
193 case 0x0049:
194 case 0x004A:
195 case 0x004B:
196 case 0x004C:
197 case 0x004D:
198 case 0x004E:
199 case 0x004F:
200 case 0x0050:
201 case 0x0051:
202 case 0x0052:
203 case 0x0053:
204 case 0x0054:
205 case 0x0055:
206 case 0x0056:
207 case 0x0057:
208 case 0x0058:
209 case 0x0059:
210 case 0x005A:
211 case 0x005B:
212 case 0x005C:
213 case 0x005D:
214 case 0x005E:
215 case 0x005F:
216 case 0x0060:
217 case 0x0061:
218 case 0x0062:
219 case 0x0063:
220 case 0x0064:
221 case 0x0065:
222 case 0x0066:
223 case 0x0067:
224 case 0x0068:
225 case 0x0069:
226 case 0x006A:
227 case 0x006B:
228 case 0x006C:
229 case 0x006D:
230 case 0x006E:
231 case 0x006F:
232 case 0x0070:
233 case 0x0071:
234 case 0x0072:
235 case 0x0073:
236 case 0x0074:
237 case 0x0075:
238 case 0x0076:
239 case 0x0077:
240 case 0x0078:
241 case 0x0079:
242 case 0x007A:
243 case 0x007B:
244 case 0x007C:
245 case 0x007D:
246 case 0x007E:
247 break;
248 case 0x001A: ch = 0x7F; break;
249 case 0x001C: ch = 0x1A; break;
250 case 0x007F: ch = 0x1C; break;
251 case 0x00A0: ch = 0xFF; break;
252 case 0x00A2: ch = 0xFC; break;
253 case 0x00A6: ch = 0xFE; break;
254 case 0x00AC: ch = 0xFD; break;
255 case 0x0E01:
256 case 0x0E02:
257 case 0x0E03:
258 case 0x0E04:
259 case 0x0E05:
260 case 0x0E06:
261 case 0x0E07:
262 case 0x0E08:
263 case 0x0E09:
264 case 0x0E0A:
265 case 0x0E0B:
266 case 0x0E0C:
267 case 0x0E0D:
268 case 0x0E0E:
269 case 0x0E0F:
270 case 0x0E10:
271 case 0x0E11:
272 case 0x0E12:
273 case 0x0E13:
274 case 0x0E14:
275 case 0x0E15:
276 case 0x0E16:
277 case 0x0E17:
278 case 0x0E18:
279 case 0x0E19:
280 case 0x0E1A:
281 case 0x0E1B:
282 case 0x0E1C:
283 case 0x0E1D:
284 case 0x0E1E:
285 case 0x0E1F:
286 case 0x0E20:
287 case 0x0E21:
288 case 0x0E22:
289 case 0x0E23:
290 case 0x0E24:
291 case 0x0E25:
292 case 0x0E26:
293 case 0x0E27:
294 case 0x0E28:
295 case 0x0E29:
296 case 0x0E2A:
297 case 0x0E2B:
298 case 0x0E2C:
299 case 0x0E2D:
300 case 0x0E2E:
301 case 0x0E2F:
302 case 0x0E30:
303 case 0x0E31:
304 case 0x0E32:
305 case 0x0E33:
306 case 0x0E34:
307 case 0x0E35:
308 case 0x0E36:
309 case 0x0E37:
310 case 0x0E38:
311 case 0x0E39:
312 case 0x0E3A:
313 ch -= 0x0D60;
314 break;
315 case 0x0E3F:
316 case 0x0E40:
317 case 0x0E41:
318 case 0x0E42:
319 case 0x0E43:
320 case 0x0E44:
321 case 0x0E45:
322 case 0x0E46:
323 case 0x0E47:
324 case 0x0E48:
325 case 0x0E49:
326 case 0x0E4A:
327 case 0x0E4B:
328 case 0x0E4C:
329 case 0x0E4D:
330 case 0x0E4E:
331 case 0x0E4F:
332 case 0x0E50:
333 case 0x0E51:
334 case 0x0E52:
335 case 0x0E53:
336 case 0x0E54:
337 case 0x0E55:
338 case 0x0E56:
339 case 0x0E57:
340 case 0x0E58:
341 case 0x0E59:
342 case 0x0E5A:
343 case 0x0E5B:
344 ch -= 0x0D60;
345 break;
346 default:
347 {
348 if(ch >= 0xFF01 && ch <= 0xFF5E)
349 {
350 ch -= 0xFEE0;
351 }
352 else
353 {
354 HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
355 charIndex++;
356 charCount--;
357 continue;
358 }
359 }
360 break;
361 }
362 //Write encoded byte to buffer, if buffer is defined and fallback was not used
363 if (bytes != null)
364 bytes[byteIndex] = (byte)ch;
365 byteIndex++;
366 byteCount--;
367 charIndex++;
368 charCount--;
369 }
370 return byteIndex;
371 }
372 }; // class CP874
373
374 [Serializable]
375 public class ENCwindows_874 : CP874
376 {
377 public ENCwindows_874() : base() {}
378
379 }; // class ENCwindows_874
380
381 }; // namespace I18N.Other