1 /**************************************************************************** 2 ** 3 ** Copyright (C) 2016 The Qt Company Ltd. 4 ** Contact: https://www.qt.io/licensing/ 5 ** 6 ** This file is part of the Qt Virtual Keyboard module of the Qt Toolkit. 7 ** 8 ** $QT_BEGIN_LICENSE:GPL$ 9 ** Commercial License Usage 10 ** Licensees holding valid commercial Qt licenses may use this file in 11 ** accordance with the commercial license agreement provided with the 12 ** Software or, alternatively, in accordance with the terms contained in 13 ** a written agreement between you and The Qt Company. For licensing terms 14 ** and conditions see https://www.qt.io/terms-conditions. For further 15 ** information use the contact form at https://www.qt.io/contact-us. 16 ** 17 ** GNU General Public License Usage 18 ** Alternatively, this file may be used under the terms of the GNU 19 ** General Public License version 3 or (at your option) any later version 20 ** approved by the KDE Free Qt Foundation. The licenses are as published by 21 ** the Free Software Foundation and appearing in the file LICENSE.GPL3 22 ** included in the packaging of this file. Please review the following 23 ** information to ensure the GNU General Public License requirements will 24 ** be met: https://www.gnu.org/licenses/gpl-3.0.html. 25 ** 26 ** $QT_END_LICENSE$ 27 ** 28 ****************************************************************************/ 29 30 #ifndef HANGUL_P_H 31 #define HANGUL_P_H 32 33 // 34 // W A R N I N G 35 // ------------- 36 // 37 // This file is not part of the Qt API. It exists purely as an 38 // implementation detail. This header file may change from version to 39 // version without notice, or even be removed. 40 // 41 // We mean it. 42 // 43 44 #include <QString> 45 #include <QList> 46 #include <QMap> 47 48 QT_BEGIN_NAMESPACE 49 namespace QtVirtualKeyboard { 50 51 class Hangul 52 { 53 Q_DISABLE_COPY(Hangul) 54 55 enum HangulMedialIndex { // VIndex Letter Jungseong Double Jamo 56 // ---------------------------------------------------------------------- 57 HANGUL_MEDIAL_A, // 0 314F 1161 58 HANGUL_MEDIAL_AE, // 1 3150 1162 59 HANGUL_MEDIAL_YA, // 2 3151 1163 60 HANGUL_MEDIAL_YAE, // 3 3152 1164 61 HANGUL_MEDIAL_EO, // 4 3153 1165 62 HANGUL_MEDIAL_E, // 5 3154 1166 63 HANGUL_MEDIAL_YEO, // 6 3155 1167 64 HANGUL_MEDIAL_YE, // 7 3156 1168 65 HANGUL_MEDIAL_O, // 8 3157 1169 66 HANGUL_MEDIAL_WA, // 9 3158 116A 3157+314F 67 HANGUL_MEDIAL_WAE, // 10 3159 116B 3157+3150 68 HANGUL_MEDIAL_OE, // 11 315A 116C 3157+3163 69 HANGUL_MEDIAL_YO, // 12 315B 116D 70 HANGUL_MEDIAL_U, // 13 315C 116E 71 HANGUL_MEDIAL_WEO, // 14 315D 116F 315C+3153 72 HANGUL_MEDIAL_WE, // 15 315E 1170 315C+3154 73 HANGUL_MEDIAL_WI, // 16 315F 1171 315C+3163 74 HANGUL_MEDIAL_YU, // 17 3160 1172 75 HANGUL_MEDIAL_EU, // 18 3161 1173 76 HANGUL_MEDIAL_YI, // 19 3162 1174 3161+3163 77 HANGUL_MEDIAL_I // 20 3163 1175 78 }; 79 80 enum HangulFinalIndex { // TIndex Letter Jongseong Double Jamo 81 // ---------------------------------------------------------------------- 82 HANGUL_FINAL_NONE, // 0 n/a n/a 83 HANGUL_FINAL_KIYEOK, // 1 3131 11A8 84 HANGUL_FINAL_SSANGKIYEOK, // 2 3132 11A9 85 HANGUL_FINAL_KIYEOK_SIOS, // 3 3133 11AA 3131+3145 86 HANGUL_FINAL_NIEUN, // 4 3134 11AB 87 HANGUL_FINAL_NIEUN_CIEUC, // 5 3135 11AC 3134+3148 88 HANGUL_FINAL_NIEUN_HIEUH, // 6 3136 11AD 3134+314E 89 HANGUL_FINAL_TIKEUT, // 7 3137 11AE 90 HANGUL_FINAL_RIEUL, // 8 3139 11AF 91 HANGUL_FINAL_RIEUL_KIYEOK, // 9 313A 11B0 3139+3131 92 HANGUL_FINAL_RIEUL_MIEUM, // 10 313B 11B1 3139+3141 93 HANGUL_FINAL_RIEUL_PIEUP, // 11 313C 11B2 3139+3142 94 HANGUL_FINAL_RIEUL_SIOS, // 12 313D 11B3 3139+3145 95 HANGUL_FINAL_RIEUL_THIEUTH, // 13 313E 11B4 3139+314C 96 HANGUL_FINAL_RIEUL_PHIEUPH, // 14 313F 11B5 3139+314D 97 HANGUL_FINAL_RIEUL_HIEUH, // 15 3140 11B6 3139+314E 98 HANGUL_FINAL_MIEUM, // 16 3141 11B7 99 HANGUL_FINAL_PIEUP, // 17 3142 11B8 100 HANGUL_FINAL_PIEUP_SIOS, // 18 3144 11B9 3142+3145 101 HANGUL_FINAL_SIOS, // 19 3145 11BA 102 HANGUL_FINAL_SSANGSIOS, // 20 3146 11BB 3145+3145 103 HANGUL_FINAL_IEUNG, // 21 3147 11BC 104 HANGUL_FINAL_CIEUC, // 22 3148 11BD 105 HANGUL_FINAL_CHIEUCH, // 23 314A 11BE 106 HANGUL_FINAL_KHIEUKH, // 24 314B 11BF 107 HANGUL_FINAL_THIEUTH, // 25 314C 11C0 108 HANGUL_FINAL_PHIEUPH, // 26 314D 11C1 109 HANGUL_FINAL_HIEUH // 27 314E 11C2 110 }; 111 112 Hangul(); 113 114 public: 115 static QString decompose(const QString &source); 116 static QString compose(const QString &source); 117 static bool isJamo(const ushort &unicode); 118 119 private: 120 static bool isMedial(HangulMedialIndex vowel); 121 static bool isFinal(HangulFinalIndex consonant); 122 static ushort findDoubleMedial(HangulMedialIndex vowel); 123 static ushort findDoubleFinal(HangulFinalIndex consonant); 124 static ushort packDoubleMedial(HangulMedialIndex a, HangulMedialIndex b); 125 static ushort packDoubleFinal(HangulFinalIndex a, HangulFinalIndex b); 126 static void unpackDoubleMedial(ushort key, HangulMedialIndex &a, HangulMedialIndex &b); 127 static void unpackDoubleFinal(ushort key, HangulFinalIndex &a, HangulFinalIndex &b); 128 static QMap<ushort, HangulMedialIndex> initDoubleMedialMap(); 129 static QMap<ushort, HangulFinalIndex> initDoubleFinalMap(); 130 131 static const QList<ushort> initials; 132 static const QList<ushort> finals; 133 static const QMap<ushort, HangulMedialIndex> doubleMedialMap; 134 static const QMap<ushort, HangulFinalIndex> doubleFinalMap; 135 static const int SBase; 136 static const int LBase; 137 static const int VBase; 138 static const int TBase; 139 static const int LCount; 140 static const int VCount; 141 static const int TCount; 142 static const int NCount; 143 static const int SCount; 144 }; 145 146 } // namespace QtVirtualKeyboard 147 QT_END_NAMESPACE 148 149 #endif 150