|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * Hangul.php |
| 5 | + * |
| 6 | + * @since 2026-04-30 |
| 7 | + * @category Library |
| 8 | + * @package Unicode |
| 9 | + * @author Nicola Asuni <info@tecnick.com> |
| 10 | + * @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD |
| 11 | + * @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) |
| 12 | + * @link https://github.com/tecnickcom/tc-lib-unicode |
| 13 | + * |
| 14 | + * This file is part of tc-lib-unicode software library. |
| 15 | + * |
| 16 | + * Source: The Unicode Standard, version 15.1, section 3.12 "Conjoining Jamo Behavior" |
| 17 | + * https://www.unicode.org/versions/Unicode15.1.0/ |
| 18 | + * https://unicode.org/Public/15.1.0/ucd/UnicodeData.txt |
| 19 | + * Unicode Standard version: 15.1 |
| 20 | + */ |
| 21 | + |
| 22 | +namespace Com\Tecnick\Unicode\Data; |
| 23 | + |
| 24 | +/** |
| 25 | + * Com\Tecnick\Unicode\Data\Hangul |
| 26 | + * |
| 27 | + * Algorithmic constants for Hangul Jamo → precomposed Hangul syllable |
| 28 | + * composition, as defined in section 3.12 of the Unicode Standard. |
| 29 | + * |
| 30 | + * Precomposed syllables occupy the range U+AC00–U+D7A3 and are derived by: |
| 31 | + * |
| 32 | + * S = SBase + (L − LBase) × NCount + (V − VBase) × TCount + (T − TBase) |
| 33 | + * |
| 34 | + * where T = TBase means "no trailing consonant" (TBase itself is not a |
| 35 | + * trailing consonant; the effective trailing index is 0 in that case). |
| 36 | + * |
| 37 | + * @since 2026-04-30 |
| 38 | + * @category Library |
| 39 | + * @package Unicode |
| 40 | + * @author Nicola Asuni <info@tecnick.com> |
| 41 | + * @copyright 2011-2026 Nicola Asuni - Tecnick.com LTD |
| 42 | + * @license https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT) |
| 43 | + * @link https://github.com/tecnickcom/tc-lib-unicode |
| 44 | + */ |
| 45 | +final class Hangul |
| 46 | +{ |
| 47 | + /** |
| 48 | + * First precomposed Hangul syllable: U+AC00 HANGUL SYLLABLE GA. |
| 49 | + * |
| 50 | + * Source: Unicode Standard 15.1, section 3.12 |
| 51 | + */ |
| 52 | + public const SBASE = 0xAC00; |
| 53 | + |
| 54 | + /** |
| 55 | + * First Hangul leading consonant (choseong): U+1100 HANGUL CHOSEONG KIYEOK. |
| 56 | + * |
| 57 | + * Source: Unicode Standard 15.1, section 3.12 |
| 58 | + */ |
| 59 | + public const LBASE = 0x1100; |
| 60 | + |
| 61 | + /** |
| 62 | + * First Hangul vowel (jungseong): U+1161 HANGUL JUNGSEONG A. |
| 63 | + * |
| 64 | + * Source: Unicode Standard 15.1, section 3.12 |
| 65 | + */ |
| 66 | + public const VBASE = 0x1161; |
| 67 | + |
| 68 | + /** |
| 69 | + * Trailing consonant base value: U+11A7. |
| 70 | + * |
| 71 | + * The first actual trailing consonant (jongseong) is U+11A8; TBase is |
| 72 | + * one below that, so that (T − TBase) gives a 1-based index and a T of |
| 73 | + * TBase itself encodes "no trailing consonant" (index 0). |
| 74 | + * |
| 75 | + * Source: Unicode Standard 15.1, section 3.12 |
| 76 | + */ |
| 77 | + public const TBASE = 0x11A7; |
| 78 | + |
| 79 | + /** |
| 80 | + * Number of leading consonants (19). |
| 81 | + * |
| 82 | + * Covers U+1100–U+1112. |
| 83 | + * |
| 84 | + * Source: Unicode Standard 15.1, section 3.12 |
| 85 | + */ |
| 86 | + public const LCOUNT = 19; |
| 87 | + |
| 88 | + /** |
| 89 | + * Number of vowels (21). |
| 90 | + * |
| 91 | + * Covers U+1161–U+1175. |
| 92 | + * |
| 93 | + * Source: Unicode Standard 15.1, section 3.12 |
| 94 | + */ |
| 95 | + public const VCOUNT = 21; |
| 96 | + |
| 97 | + /** |
| 98 | + * Number of trailing consonant slots (28), including the "none" slot. |
| 99 | + * |
| 100 | + * Effective trailing consonants: U+11A8–U+11C2 (27 codepoints). |
| 101 | + * The 28th slot represents absence of a trailing consonant. |
| 102 | + * |
| 103 | + * Source: Unicode Standard 15.1, section 3.12 |
| 104 | + */ |
| 105 | + public const TCOUNT = 28; |
| 106 | + |
| 107 | + /** |
| 108 | + * Number of precomposed syllables per leading consonant. |
| 109 | + * |
| 110 | + * NCount = VCount × TCount = 21 × 28 = 588. |
| 111 | + * |
| 112 | + * Source: Unicode Standard 15.1, section 3.12 |
| 113 | + */ |
| 114 | + public const NCOUNT = self::VCOUNT * self::TCOUNT; |
| 115 | + |
| 116 | + /** |
| 117 | + * Total number of precomposed Hangul syllables. |
| 118 | + * |
| 119 | + * SCount = LCount × NCount = 19 × 588 = 11172. |
| 120 | + * |
| 121 | + * Source: Unicode Standard 15.1, section 3.12 |
| 122 | + */ |
| 123 | + public const SCOUNT = self::LCOUNT * self::NCOUNT; |
| 124 | +} |
0 commit comments