diff options
| author | Kenichi Handa | 2004-01-27 12:12:16 +0000 |
|---|---|---|
| committer | Kenichi Handa | 2004-01-27 12:12:16 +0000 |
| commit | 6e58724efc586ada8f20713ea15b0e21e1092b24 (patch) | |
| tree | f02c82be3d9f91f2aa0a9e1af30f2e996dc05c9d /src/coding.h | |
| parent | 57a47f8a1402eb7115ab9f849a8a70b43ecab228 (diff) | |
| download | emacs-6e58724efc586ada8f20713ea15b0e21e1092b24.tar.gz emacs-6e58724efc586ada8f20713ea15b0e21e1092b24.zip | |
(SJIS_TO_JIS2, JIS_TO_SJIS2): New macros.
Diffstat (limited to 'src/coding.h')
| -rw-r--r-- | src/coding.h | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/src/coding.h b/src/coding.h index 2a495e4b3d1..4988a1218fd 100644 --- a/src/coding.h +++ b/src/coding.h | |||
| @@ -479,6 +479,31 @@ struct coding_system | |||
| 479 | (code) = (j1 << 8) | j2; \ | 479 | (code) = (j1 << 8) | j2; \ |
| 480 | } while (0) | 480 | } while (0) |
| 481 | 481 | ||
| 482 | #define SJIS_TO_JIS2(code) \ | ||
| 483 | do { \ | ||
| 484 | int s1, s2, j1, j2; \ | ||
| 485 | \ | ||
| 486 | s1 = (code) >> 8, s2 = (code) & 0xFF; \ | ||
| 487 | \ | ||
| 488 | if (s2 >= 0x9F) \ | ||
| 489 | { \ | ||
| 490 | j1 = (s1 == 0xF0 ? 0x28 \ | ||
| 491 | : s1 == 0xF1 ? 0x24 \ | ||
| 492 | : s1 == 0xF2 ? 0x2C \ | ||
| 493 | : s1 == 0xF3 ? 0x2E \ | ||
| 494 | : 0x6E + (s1 - 0xF4) * 2); \ | ||
| 495 | j2 = s2 - 0x7E; \ | ||
| 496 | } \ | ||
| 497 | else \ | ||
| 498 | { \ | ||
| 499 | j1 = (s1 <= 0xF2 ? 0x21 + (s1 - 0xF0) * 2 \ | ||
| 500 | : s1 <= 0xF4 ? 0x2D + (s1 - 0xF3) * 2 \ | ||
| 501 | : 0x6F + (s1 - 0xF5) * 2); \ | ||
| 502 | j2 = s2 - ((s2 >= 0x7F ? 0x20 : 0x1F)); \ | ||
| 503 | } \ | ||
| 504 | (code) = (j1 << 8) | j2; \ | ||
| 505 | } while (0) | ||
| 506 | |||
| 482 | 507 | ||
| 483 | #define JIS_TO_SJIS(code) \ | 508 | #define JIS_TO_SJIS(code) \ |
| 484 | do { \ | 509 | do { \ |
| @@ -494,6 +519,29 @@ struct coding_system | |||
| 494 | (code) = (s1 << 8) | s2; \ | 519 | (code) = (s1 << 8) | s2; \ |
| 495 | } while (0) | 520 | } while (0) |
| 496 | 521 | ||
| 522 | #define JIS_TO_SJIS2(code) \ | ||
| 523 | do { \ | ||
| 524 | int s1, s2, j1, j2; \ | ||
| 525 | \ | ||
| 526 | j1 = (code) >> 8, j2 = (code) & 0xFF; \ | ||
| 527 | if (j1 & 1) \ | ||
| 528 | { \ | ||
| 529 | s1 = (j1 <= 0x25 ? 0xF0 + (j1 - 0x21) / 2 \ | ||
| 530 | : j1 <= 0x27 ? 0xF3 + (j1 - 0x2D) / 2 \ | ||
| 531 | : 0xF5 + (j1 - 0x6F) / 2); \ | ||
| 532 | s2 = j2 + ((j2 >= 0x60) ? 0x20 : 0x1F); \ | ||
| 533 | } \ | ||
| 534 | else \ | ||
| 535 | { \ | ||
| 536 | s1 = (j1 == 0x28 ? 0xF0 \ | ||
| 537 | : j1 == 0x24 ? 0xF1 \ | ||
| 538 | : j1 == 0x2C ? 0xF2 \ | ||
| 539 | : j1 == 0x2E ? 0xF3 \ | ||
| 540 | : 0xF4 + (j1 - 0x6E) / 2); \ | ||
| 541 | s2 = j2 + 0x7E; \ | ||
| 542 | } \ | ||
| 543 | (code) = (s1 << 8) | s2; \ | ||
| 544 | } while (0) | ||
| 497 | 545 | ||
| 498 | /* Encode the file name NAME using the specified coding system | 546 | /* Encode the file name NAME using the specified coding system |
| 499 | for file names, if any. */ | 547 | for file names, if any. */ |