Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 1 | #define JISX0201_R_ENCODE(c, assi) \ |
| 2 | if ((c) < 0x80 && (c) != 0x5c && (c) != 0x7e) \ |
| 3 | (assi) = (c); \ |
| 4 | else if ((c) == 0x00a5) (assi) = 0x5c; \ |
| 5 | else if ((c) == 0x203e) (assi) = 0x7e; |
| 6 | #define JISX0201_K_ENCODE(c, assi) \ |
| 7 | if ((c) >= 0xff61 && (c) <= 0xff9f) \ |
| 8 | (assi) = (c) - 0xfec0; |
| 9 | #define JISX0201_ENCODE(c, assi) \ |
| 10 | JISX0201_R_ENCODE(c, assi) \ |
| 11 | else JISX0201_K_ENCODE(c, assi) |
Hye-Shik Chang | 3e2a306 | 2004-01-17 14:29:29 +0000 | [diff] [blame] | 12 | |
Victor Stinner | a0dd021 | 2013-04-11 22:09:04 +0200 | [diff] [blame] | 13 | #define JISX0201_R_DECODE_CHAR(c, assi) \ |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 14 | if ((c) < 0x5c) (assi) = (c); \ |
| 15 | else if ((c) == 0x5c) (assi) = 0x00a5; \ |
| 16 | else if ((c) < 0x7e) (assi) = (c); \ |
| 17 | else if ((c) == 0x7e) (assi) = 0x203e; \ |
| 18 | else if ((c) == 0x7f) (assi) = 0x7f; |
Victor Stinner | a0dd021 | 2013-04-11 22:09:04 +0200 | [diff] [blame] | 19 | #define JISX0201_R_DECODE(c, writer) \ |
| 20 | if ((c) < 0x5c) OUTCHAR(c); \ |
| 21 | else if ((c) == 0x5c) OUTCHAR(0x00a5); \ |
| 22 | else if ((c) < 0x7e) OUTCHAR(c); \ |
| 23 | else if ((c) == 0x7e) OUTCHAR(0x203e); \ |
| 24 | else if ((c) == 0x7f) OUTCHAR(0x7f); |
| 25 | #define JISX0201_K_DECODE(c, writer) \ |
Antoine Pitrou | f95a1b3 | 2010-05-09 15:52:27 +0000 | [diff] [blame] | 26 | if ((c) >= 0xa1 && (c) <= 0xdf) \ |
Victor Stinner | a0dd021 | 2013-04-11 22:09:04 +0200 | [diff] [blame] | 27 | OUTCHAR(0xfec0 + (c)); |
| 28 | #define JISX0201_K_DECODE_CHAR(c, assi) \ |
| 29 | if ((c) >= 0xa1 && (c) <= 0xdf) \ |
| 30 | (assi) = 0xfec0 + (c); |
| 31 | #define JISX0201_DECODE(c, writer) \ |
| 32 | JISX0201_R_DECODE(c, writer) \ |
| 33 | else JISX0201_K_DECODE(c, writer) |