diff options
Diffstat (limited to 'modules')
-rw-r--r-- | modules/hangul/hangul-defs.h | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/modules/hangul/hangul-defs.h b/modules/hangul/hangul-defs.h index 59ed4625..1c6512f8 100644 --- a/modules/hangul/hangul-defs.h +++ b/modules/hangul/hangul-defs.h @@ -1,7 +1,7 @@ /* Pango * hangul-defs.h: * - * Copyright (C) 2002 Changwoo Ryu + * Copyright (C) 2002-2005 Changwoo Ryu * Author: Changwoo Ryu <cwryu@debian.org> * * This library is free software; you can redistribute it and/or @@ -20,50 +20,59 @@ * Boston, MA 02111-1307, USA. */ -/* - * From 3.10 of the Unicode 2.0 Book; used for combining Jamos. +/* See 3.12 "Conjoining Jamo Behavior" in the Unicode Book for more + * information */ + +/* The start of the Hangul Syllables (U+AC00-U+D7A3) */ #define SBASE 0xAC00 +#define SCOUNT 11172 + +/* The starts/ends of the leading consonants (choseong), the vowels + * (jungseong) and the trailing consonants (jongseong). + */ #define LBASE 0x1100 #define VBASE 0x1161 #define TBASE 0x11A7 - #define LEND 0x115F -#define VEND 0x11A6 +#define VEND 0x11A7 #define TEND 0x11FF -#define SCOUNT 11172 +/* Number of modern jamos */ #define LCOUNT 19 #define VCOUNT 21 #define TCOUNT 28 -#define NCOUNT (VCOUNT * TCOUNT) +#define NCOUNT (VCOUNT * TCOUNT) /* number of syllables of a given choseong */ -/* - * Unicode 2.0 doesn't define the fill for trailing consonants, but - * I'll use 0x11A7 as that purpose internally. - */ +/* choseong and jungseong filler */ #define LFILL 0x115F #define VFILL 0x1160 +/* Old tone marks. */ #define HTONE1 0x302E #define HTONE2 0x302F -#define IS_JAMO(wc) (wc >= LBASE && wc <= TEND) -#define IS_L(wc) (wc >= LBASE && wc <= LEND) -#define IS_V(wc) (wc >= VFILL && wc <= VEND) -#define IS_T(wc) (wc > TBASE && wc <= TEND) -#define IS_M(wc) (wc == HTONE1 || wc == HTONE2) +/* Useful macros + */ -/* jamo which can be composited as a Hangul syllable */ -#define IS_L_S(wc) (wc >= LBASE && wc < LBASE + LCOUNT) -#define IS_V_S(wc) (wc >= VBASE && wc < VBASE + VCOUNT) -#define IS_T_S(wc) (wc > TBASE && wc < TBASE + TCOUNT) +#define IS_JAMO(wc) ((wc) >= LBASE && (wc) <= TEND) +#define IS_L(wc) ((wc) >= LBASE && (wc) <= LEND) +#define IS_V(wc) ((wc) >= VFILL && (wc) <= VEND) +#define IS_T(wc) ((wc) > TBASE && (wc) <= TEND) +#define IS_M(wc) ((wc) == HTONE1 || (wc) == HTONE2) +#define IS_S(wc) (SBASE <= (wc) && (wc) < (SBASE + SCOUNT)) + +/* jamo which can be composited as a precomposed syllable */ +#define IS_L_S(wc) ((wc) >= LBASE && (wc) < (LBASE + LCOUNT)) +#define IS_V_S(wc) ((wc) >= VBASE && (wc) < (VBASE + VCOUNT)) +#define IS_T_S(wc) ((wc) > TBASE && (wc) < (TBASE + TCOUNT)) + +/* if a syllable has a jongseong */ +#define S_HAS_T(s) (((s) - SBASE) % TCOUNT) +/* composing/decomposing */ #define S_FROM_LVT(l,v,t) (SBASE + (((l) - LBASE) * VCOUNT + ((v) - VBASE)) * TCOUNT + ((t) - TBASE)) #define S_FROM_LV(l,v) (SBASE + (((l) - LBASE) * VCOUNT + ((v) - VBASE)) * TCOUNT) #define L_FROM_S(s) (LBASE + (((s) - SBASE) / NCOUNT)) #define V_FROM_S(s) (VBASE + (((s) - SBASE) % NCOUNT) / TCOUNT) #define T_FROM_S(s) (TBASE + (((s) - SBASE) % TCOUNT)) - -#define IS_S(wc) (SBASE <= (wc) && (wc) < (SBASE + SCOUNT)) -#define S_HAS_T(s) (((s) - SBASE) % TCOUNT) |