Debian Codegraph @

mcs/class/I18N/Other/CP28594.cs

raw symbols SCIP
1 /*
2 * CP28594.cs - Baltic (ISO) 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-914.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 CP28594 : ByteEncoding
39 {
40 public CP28594()
41 : base(28594, ToChars, "Baltic (ISO)",
42 "iso-8859-4", "iso-8859-4", "iso-8859-4",
43 true, true, true, true, 1257)
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', '\u001A', '\u001B', '\u001C', '\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', '\u007F', '\u0080', '\u0081', '\u0082', '\u0083',
69 '\u0084', '\u0085', '\u0086', '\u0087', '\u0088', '\u0089',
70 '\u008A', '\u008B', '\u008C', '\u008D', '\u008E', '\u008F',
71 '\u0090', '\u0091', '\u0092', '\u0093', '\u0094', '\u0095',
72 '\u0096', '\u0097', '\u0098', '\u0099', '\u009A', '\u009B',
73 '\u009C', '\u009D', '\u009E', '\u009F', '\u00A0', '\u0104',
74 '\u0138', '\u0156', '\u00A4', '\u0128', '\u013B', '\u00A7',
75 '\u00A8', '\u0160', '\u0112', '\u0122', '\u0166', '\u00AD',
76 '\u017D', '\u00AF', '\u00B0', '\u0105', '\u02DB', '\u0157',
77 '\u00B4', '\u0129', '\u013C', '\u02C7', '\u00B8', '\u0161',
78 '\u0113', '\u0123', '\u0167', '\u014A', '\u017E', '\u014B',
79 '\u0100', '\u00C1', '\u00C2', '\u00C3', '\u00C4', '\u00C5',
80 '\u00C6', '\u012E', '\u010C', '\u00C9', '\u0118', '\u00CB',
81 '\u0116', '\u00CD', '\u00CE', '\u012A', '\u0110', '\u0145',
82 '\u014C', '\u0136', '\u00D4', '\u00D5', '\u00D6', '\u00D7',
83 '\u00D8', '\u0172', '\u00DA', '\u00DB', '\u00DC', '\u0168',
84 '\u016A', '\u00DF', '\u0101', '\u00E1', '\u00E2', '\u00E3',
85 '\u00E4', '\u00E5', '\u00E6', '\u012F', '\u010D', '\u00E9',
86 '\u0119', '\u00EB', '\u0117', '\u00ED', '\u00EE', '\u012B',
87 '\u0111', '\u0146', '\u014D', '\u0137', '\u00F4', '\u00F5',
88 '\u00F6', '\u00F7', '\u00F8', '\u0173', '\u00FA', '\u00FB',
89 '\u00FC', '\u0169', '\u016B', '\u02D9',
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 >= 161) switch(ch)
147 {
148 case 0x00A4:
149 case 0x00A7:
150 case 0x00A8:
151 case 0x00AD:
152 case 0x00AF:
153 case 0x00B0:
154 case 0x00B4:
155 case 0x00B8:
156 case 0x00C1:
157 case 0x00C2:
158 case 0x00C3:
159 case 0x00C4:
160 case 0x00C5:
161 case 0x00C6:
162 case 0x00C9:
163 case 0x00CB:
164 case 0x00CD:
165 case 0x00CE:
166 case 0x00D4:
167 case 0x00D5:
168 case 0x00D6:
169 case 0x00D7:
170 case 0x00D8:
171 case 0x00DA:
172 case 0x00DB:
173 case 0x00DC:
174 case 0x00DF:
175 case 0x00E1:
176 case 0x00E2:
177 case 0x00E3:
178 case 0x00E4:
179 case 0x00E5:
180 case 0x00E6:
181 case 0x00E9:
182 case 0x00EB:
183 case 0x00ED:
184 case 0x00EE:
185 case 0x00F4:
186 case 0x00F5:
187 case 0x00F6:
188 case 0x00F7:
189 case 0x00F8:
190 case 0x00FA:
191 case 0x00FB:
192 case 0x00FC:
193 break;
194 case 0x0100: ch = 0xC0; break;
195 case 0x0101: ch = 0xE0; break;
196 case 0x0104: ch = 0xA1; break;
197 case 0x0105: ch = 0xB1; break;
198 case 0x010C: ch = 0xC8; break;
199 case 0x010D: ch = 0xE8; break;
200 case 0x0110: ch = 0xD0; break;
201 case 0x0111: ch = 0xF0; break;
202 case 0x0112: ch = 0xAA; break;
203 case 0x0113: ch = 0xBA; break;
204 case 0x0116: ch = 0xCC; break;
205 case 0x0117: ch = 0xEC; break;
206 case 0x0118: ch = 0xCA; break;
207 case 0x0119: ch = 0xEA; break;
208 case 0x0122: ch = 0xAB; break;
209 case 0x0123: ch = 0xBB; break;
210 case 0x0128: ch = 0xA5; break;
211 case 0x0129: ch = 0xB5; break;
212 case 0x012A: ch = 0xCF; break;
213 case 0x012B: ch = 0xEF; break;
214 case 0x012E: ch = 0xC7; break;
215 case 0x012F: ch = 0xE7; break;
216 case 0x0136: ch = 0xD3; break;
217 case 0x0137: ch = 0xF3; break;
218 case 0x0138: ch = 0xA2; break;
219 case 0x013B: ch = 0xA6; break;
220 case 0x013C: ch = 0xB6; break;
221 case 0x0145: ch = 0xD1; break;
222 case 0x0146: ch = 0xF1; break;
223 case 0x014A: ch = 0xBD; break;
224 case 0x014B: ch = 0xBF; break;
225 case 0x014C: ch = 0xD2; break;
226 case 0x014D: ch = 0xF2; break;
227 case 0x0156: ch = 0xA3; break;
228 case 0x0157: ch = 0xB3; break;
229 case 0x0160: ch = 0xA9; break;
230 case 0x0161: ch = 0xB9; break;
231 case 0x0166: ch = 0xAC; break;
232 case 0x0167: ch = 0xBC; break;
233 case 0x0168: ch = 0xDD; break;
234 case 0x0169: ch = 0xFD; break;
235 case 0x016A: ch = 0xDE; break;
236 case 0x016B: ch = 0xFE; break;
237 case 0x0172: ch = 0xD9; break;
238 case 0x0173: ch = 0xF9; break;
239 case 0x017D: ch = 0xAE; break;
240 case 0x017E: ch = 0xBE; break;
241 case 0x02C7: ch = 0xB7; break;
242 case 0x02D9: ch = 0xFF; break;
243 case 0x02DB: ch = 0xB2; break;
244 default:
245 {
246 if(ch >= 0xFF01 && ch <= 0xFF5E)
247 {
248 ch -= 0xFEE0;
249 }
250 else
251 {
252 HandleFallback (ref buffer, chars, ref charIndex, ref charCount, bytes, ref byteIndex, ref byteCount);
253 charIndex++;
254 charCount--;
255 continue;
256 }
257 }
258 break;
259 }
260 //Write encoded byte to buffer, if buffer is defined and fallback was not used
261 if (bytes != null)
262 bytes[byteIndex] = (byte)ch;
263 byteIndex++;
264 byteCount--;
265 charIndex++;
266 charCount--;
267 }
268 return byteIndex;
269 }
270 }; // class CP28594
271
272 [Serializable]
273 public class ENCiso_8859_4 : CP28594
274 {
275 public ENCiso_8859_4() : base() {}
276
277 }; // class ENCiso_8859_4
278
279 }; // namespace I18N.Other