2 * CP866.cs - Russian (DOS) code page.
4 * Copyright (c) 2002 Southern Storm Software, Pty Ltd
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:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
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.
25 // Generated from "ibm-866.ucm".
35 public class CP866
: ByteEncoding
38 : base(866, ToChars
, "Russian (DOS)",
39 "ibm866", "ibm866", "ibm866",
40 false, false, false, false, 1251)
43 private static readonly char[] ToChars
= {
44 '\u0000', '\u0001', '\u0002', '\u0003', '\u0004', '\u0005',
45 '\u0006', '\u0007', '\u0008', '\u0009', '\u000A', '\u000B',
46 '\u000C', '\u000D', '\u000E', '\u000F', '\u0010', '\u0011',
47 '\u0012', '\u0013', '\u0014', '\u0015', '\u0016', '\u0017',
48 '\u0018', '\u0019', '\u001C', '\u001B', '\u007F', '\u001D',
49 '\u001E', '\u001F', '\u0020', '\u0021', '\u0022', '\u0023',
50 '\u0024', '\u0025', '\u0026', '\u0027', '\u0028', '\u0029',
51 '\u002A', '\u002B', '\u002C', '\u002D', '\u002E', '\u002F',
52 '\u0030', '\u0031', '\u0032', '\u0033', '\u0034', '\u0035',
53 '\u0036', '\u0037', '\u0038', '\u0039', '\u003A', '\u003B',
54 '\u003C', '\u003D', '\u003E', '\u003F', '\u0040', '\u0041',
55 '\u0042', '\u0043', '\u0044', '\u0045', '\u0046', '\u0047',
56 '\u0048', '\u0049', '\u004A', '\u004B', '\u004C', '\u004D',
57 '\u004E', '\u004F', '\u0050', '\u0051', '\u0052', '\u0053',
58 '\u0054', '\u0055', '\u0056', '\u0057', '\u0058', '\u0059',
59 '\u005A', '\u005B', '\u005C', '\u005D', '\u005E', '\u005F',
60 '\u0060', '\u0061', '\u0062', '\u0063', '\u0064', '\u0065',
61 '\u0066', '\u0067', '\u0068', '\u0069', '\u006A', '\u006B',
62 '\u006C', '\u006D', '\u006E', '\u006F', '\u0070', '\u0071',
63 '\u0072', '\u0073', '\u0074', '\u0075', '\u0076', '\u0077',
64 '\u0078', '\u0079', '\u007A', '\u007B', '\u007C', '\u007D',
65 '\u007E', '\u001A', '\u0410', '\u0411', '\u0412', '\u0413',
66 '\u0414', '\u0415', '\u0416', '\u0417', '\u0418', '\u0419',
67 '\u041A', '\u041B', '\u041C', '\u041D', '\u041E', '\u041F',
68 '\u0420', '\u0421', '\u0422', '\u0423', '\u0424', '\u0425',
69 '\u0426', '\u0427', '\u0428', '\u0429', '\u042A', '\u042B',
70 '\u042C', '\u042D', '\u042E', '\u042F', '\u0430', '\u0431',
71 '\u0432', '\u0433', '\u0434', '\u0435', '\u0436', '\u0437',
72 '\u0438', '\u0439', '\u043A', '\u043B', '\u043C', '\u043D',
73 '\u043E', '\u043F', '\u2591', '\u2592', '\u2593', '\u2502',
74 '\u2524', '\u2561', '\u2562', '\u2556', '\u2555', '\u2563',
75 '\u2551', '\u2557', '\u255D', '\u255C', '\u255B', '\u2510',
76 '\u2514', '\u2534', '\u252C', '\u251C', '\u2500', '\u253C',
77 '\u255E', '\u255F', '\u255A', '\u2554', '\u2569', '\u2566',
78 '\u2560', '\u2550', '\u256C', '\u2567', '\u2568', '\u2564',
79 '\u2565', '\u2559', '\u2558', '\u2552', '\u2553', '\u256B',
80 '\u256A', '\u2518', '\u250C', '\u2588', '\u2584', '\u258C',
81 '\u2590', '\u2580', '\u0440', '\u0441', '\u0442', '\u0443',
82 '\u0444', '\u0445', '\u0446', '\u0447', '\u0448', '\u0449',
83 '\u044A', '\u044B', '\u044C', '\u044D', '\u044E', '\u044F',
84 '\u0401', '\u0451', '\u0404', '\u0454', '\u0407', '\u0457',
85 '\u040E', '\u045E', '\u00B0', '\u2219', '\u00B7', '\u221A',
86 '\u2116', '\u00A4', '\u25A0', '\u00A0',
89 protected unsafe override void ToBytes(char* chars
, int charCount
,
90 byte* bytes
, int byteCount
)
96 EncoderFallbackBuffer buffer
= null;
100 ch
= (int)(chars
[charIndex
++]);
101 if(ch
>= 26) switch(ch
)
203 case 0x001A: ch
= 0x7F; break;
204 case 0x001C: ch
= 0x1A; break;
205 case 0x007F: ch
= 0x1C; break;
206 case 0x00A0: ch
= 0xFF; break;
207 case 0x00A4: ch
= 0xFD; break;
208 case 0x00A7: ch
= 0x15; break;
209 case 0x00B0: ch
= 0xF8; break;
210 case 0x00B6: ch
= 0x14; break;
211 case 0x00B7: ch
= 0xFA; break;
212 case 0x0401: ch
= 0xF0; break;
213 case 0x0404: ch
= 0xF2; break;
214 case 0x0407: ch
= 0xF4; break;
215 case 0x040E: ch
= 0xF6; break;
284 case 0x0451: ch
= 0xF1; break;
285 case 0x0454: ch
= 0xF3; break;
286 case 0x0457: ch
= 0xF5; break;
287 case 0x045E: ch
= 0xF7; break;
288 case 0x2022: ch
= 0x07; break;
289 case 0x203C: ch
= 0x13; break;
290 case 0x2116: ch
= 0xFC; break;
291 case 0x2190: ch
= 0x1B; break;
292 case 0x2191: ch
= 0x18; break;
293 case 0x2192: ch
= 0x1A; break;
294 case 0x2193: ch
= 0x19; break;
295 case 0x2194: ch
= 0x1D; break;
296 case 0x2195: ch
= 0x12; break;
297 case 0x21A8: ch
= 0x17; break;
298 case 0x2219: ch
= 0xF9; break;
299 case 0x221A: ch
= 0xFB; break;
300 case 0x221F: ch
= 0x1C; break;
301 case 0x2302: ch
= 0x7F; break;
302 case 0x2500: ch
= 0xC4; break;
303 case 0x2502: ch
= 0xB3; break;
304 case 0x250C: ch
= 0xDA; break;
305 case 0x2510: ch
= 0xBF; break;
306 case 0x2514: ch
= 0xC0; break;
307 case 0x2518: ch
= 0xD9; break;
308 case 0x251C: ch
= 0xC3; break;
309 case 0x2524: ch
= 0xB4; break;
310 case 0x252C: ch
= 0xC2; break;
311 case 0x2534: ch
= 0xC1; break;
312 case 0x253C: ch
= 0xC5; break;
313 case 0x2550: ch
= 0xCD; break;
314 case 0x2551: ch
= 0xBA; break;
315 case 0x2552: ch
= 0xD5; break;
316 case 0x2553: ch
= 0xD6; break;
317 case 0x2554: ch
= 0xC9; break;
318 case 0x2555: ch
= 0xB8; break;
319 case 0x2556: ch
= 0xB7; break;
320 case 0x2557: ch
= 0xBB; break;
321 case 0x2558: ch
= 0xD4; break;
322 case 0x2559: ch
= 0xD3; break;
323 case 0x255A: ch
= 0xC8; break;
324 case 0x255B: ch
= 0xBE; break;
325 case 0x255C: ch
= 0xBD; break;
326 case 0x255D: ch
= 0xBC; break;
327 case 0x255E: ch
= 0xC6; break;
328 case 0x255F: ch
= 0xC7; break;
329 case 0x2560: ch
= 0xCC; break;
330 case 0x2561: ch
= 0xB5; break;
331 case 0x2562: ch
= 0xB6; break;
332 case 0x2563: ch
= 0xB9; break;
333 case 0x2564: ch
= 0xD1; break;
334 case 0x2565: ch
= 0xD2; break;
335 case 0x2566: ch
= 0xCB; break;
336 case 0x2567: ch
= 0xCF; break;
337 case 0x2568: ch
= 0xD0; break;
338 case 0x2569: ch
= 0xCA; break;
339 case 0x256A: ch
= 0xD8; break;
340 case 0x256B: ch
= 0xD7; break;
341 case 0x256C: ch
= 0xCE; break;
342 case 0x2580: ch
= 0xDF; break;
343 case 0x2584: ch
= 0xDC; break;
344 case 0x2588: ch
= 0xDB; break;
345 case 0x258C: ch
= 0xDD; break;
346 case 0x2590: ch
= 0xDE; break;
347 case 0x2591: ch
= 0xB0; break;
348 case 0x2592: ch
= 0xB1; break;
349 case 0x2593: ch
= 0xB2; break;
350 case 0x25A0: ch
= 0xFE; break;
351 case 0x25AC: ch
= 0x16; break;
352 case 0x25B2: ch
= 0x1E; break;
353 case 0x25BA: ch
= 0x10; break;
354 case 0x25BC: ch
= 0x1F; break;
355 case 0x25C4: ch
= 0x11; break;
356 case 0x25CB: ch
= 0x09; break;
357 case 0x25D8: ch
= 0x08; break;
358 case 0x25D9: ch
= 0x0A; break;
359 case 0x263A: ch
= 0x01; break;
360 case 0x263B: ch
= 0x02; break;
361 case 0x263C: ch
= 0x0F; break;
362 case 0x2640: ch
= 0x0C; break;
363 case 0x2642: ch
= 0x0B; break;
364 case 0x2660: ch
= 0x06; break;
365 case 0x2663: ch
= 0x05; break;
366 case 0x2665: ch
= 0x03; break;
367 case 0x2666: ch
= 0x04; break;
368 case 0x266A: ch
= 0x0D; break;
369 case 0x266B: ch
= 0x0E; break;
370 case 0xFFE8: ch
= 0xB3; break;
371 case 0xFFE9: ch
= 0x1B; break;
372 case 0xFFEA: ch
= 0x18; break;
373 case 0xFFEB: ch
= 0x1A; break;
374 case 0xFFEC: ch
= 0x19; break;
375 case 0xFFED: ch
= 0xFE; break;
376 case 0xFFEE: ch
= 0x09; break;
379 if(ch
>= 0xFF01 && ch
<= 0xFF5E)
383 HandleFallback (ref buffer
, chars
, ref charIndex
, ref charCount
, bytes
, ref byteIndex
, ref byteCount
);
390 bytes
[byteIndex
++] = (byte)ch
;
397 protected override void ToBytes(String s, int charIndex, int charCount,
398 byte[] bytes, int byteIndex)
403 ch = (int)(s[charIndex++]);
404 if(ch >= 26) switch(ch)
506 case 0x001A: ch = 0x7F; break;
507 case 0x001C: ch = 0x1A; break;
508 case 0x007F: ch = 0x1C; break;
509 case 0x00A0: ch = 0xFF; break;
510 case 0x00A4: ch = 0xFD; break;
511 case 0x00A7: ch = 0x15; break;
512 case 0x00B0: ch = 0xF8; break;
513 case 0x00B6: ch = 0x14; break;
514 case 0x00B7: ch = 0xFA; break;
515 case 0x0401: ch = 0xF0; break;
516 case 0x0404: ch = 0xF2; break;
517 case 0x0407: ch = 0xF4; break;
518 case 0x040E: ch = 0xF6; break;
587 case 0x0451: ch = 0xF1; break;
588 case 0x0454: ch = 0xF3; break;
589 case 0x0457: ch = 0xF5; break;
590 case 0x045E: ch = 0xF7; break;
591 case 0x2022: ch = 0x07; break;
592 case 0x203C: ch = 0x13; break;
593 case 0x2116: ch = 0xFC; break;
594 case 0x2190: ch = 0x1B; break;
595 case 0x2191: ch = 0x18; break;
596 case 0x2192: ch = 0x1A; break;
597 case 0x2193: ch = 0x19; break;
598 case 0x2194: ch = 0x1D; break;
599 case 0x2195: ch = 0x12; break;
600 case 0x21A8: ch = 0x17; break;
601 case 0x2219: ch = 0xF9; break;
602 case 0x221A: ch = 0xFB; break;
603 case 0x221F: ch = 0x1C; break;
604 case 0x2302: ch = 0x7F; break;
605 case 0x2500: ch = 0xC4; break;
606 case 0x2502: ch = 0xB3; break;
607 case 0x250C: ch = 0xDA; break;
608 case 0x2510: ch = 0xBF; break;
609 case 0x2514: ch = 0xC0; break;
610 case 0x2518: ch = 0xD9; break;
611 case 0x251C: ch = 0xC3; break;
612 case 0x2524: ch = 0xB4; break;
613 case 0x252C: ch = 0xC2; break;
614 case 0x2534: ch = 0xC1; break;
615 case 0x253C: ch = 0xC5; break;
616 case 0x2550: ch = 0xCD; break;
617 case 0x2551: ch = 0xBA; break;
618 case 0x2552: ch = 0xD5; break;
619 case 0x2553: ch = 0xD6; break;
620 case 0x2554: ch = 0xC9; break;
621 case 0x2555: ch = 0xB8; break;
622 case 0x2556: ch = 0xB7; break;
623 case 0x2557: ch = 0xBB; break;
624 case 0x2558: ch = 0xD4; break;
625 case 0x2559: ch = 0xD3; break;
626 case 0x255A: ch = 0xC8; break;
627 case 0x255B: ch = 0xBE; break;
628 case 0x255C: ch = 0xBD; break;
629 case 0x255D: ch = 0xBC; break;
630 case 0x255E: ch = 0xC6; break;
631 case 0x255F: ch = 0xC7; break;
632 case 0x2560: ch = 0xCC; break;
633 case 0x2561: ch = 0xB5; break;
634 case 0x2562: ch = 0xB6; break;
635 case 0x2563: ch = 0xB9; break;
636 case 0x2564: ch = 0xD1; break;
637 case 0x2565: ch = 0xD2; break;
638 case 0x2566: ch = 0xCB; break;
639 case 0x2567: ch = 0xCF; break;
640 case 0x2568: ch = 0xD0; break;
641 case 0x2569: ch = 0xCA; break;
642 case 0x256A: ch = 0xD8; break;
643 case 0x256B: ch = 0xD7; break;
644 case 0x256C: ch = 0xCE; break;
645 case 0x2580: ch = 0xDF; break;
646 case 0x2584: ch = 0xDC; break;
647 case 0x2588: ch = 0xDB; break;
648 case 0x258C: ch = 0xDD; break;
649 case 0x2590: ch = 0xDE; break;
650 case 0x2591: ch = 0xB0; break;
651 case 0x2592: ch = 0xB1; break;
652 case 0x2593: ch = 0xB2; break;
653 case 0x25A0: ch = 0xFE; break;
654 case 0x25AC: ch = 0x16; break;
655 case 0x25B2: ch = 0x1E; break;
656 case 0x25BA: ch = 0x10; break;
657 case 0x25BC: ch = 0x1F; break;
658 case 0x25C4: ch = 0x11; break;
659 case 0x25CB: ch = 0x09; break;
660 case 0x25D8: ch = 0x08; break;
661 case 0x25D9: ch = 0x0A; break;
662 case 0x263A: ch = 0x01; break;
663 case 0x263B: ch = 0x02; break;
664 case 0x263C: ch = 0x0F; break;
665 case 0x2640: ch = 0x0C; break;
666 case 0x2642: ch = 0x0B; break;
667 case 0x2660: ch = 0x06; break;
668 case 0x2663: ch = 0x05; break;
669 case 0x2665: ch = 0x03; break;
670 case 0x2666: ch = 0x04; break;
671 case 0x266A: ch = 0x0D; break;
672 case 0x266B: ch = 0x0E; break;
673 case 0xFFE8: ch = 0xB3; break;
674 case 0xFFE9: ch = 0x1B; break;
675 case 0xFFEA: ch = 0x18; break;
676 case 0xFFEB: ch = 0x1A; break;
677 case 0xFFEC: ch = 0x19; break;
678 case 0xFFED: ch = 0xFE; break;
679 case 0xFFEE: ch = 0x09; break;
682 if(ch >= 0xFF01 && ch <= 0xFF5E)
689 bytes[byteIndex++] = (byte)ch;
698 public class ENCibm866
: CP866
700 public ENCibm866() : base() {}
702 }; // class ENCibm866
704 }; // namespace I18N.Rare