Make the build process informative again for 'make' 3.80 and earlier. Those 'make...
[Rockbox.git] / firmware / hangul.c
blob27123ccb6476448bcb50142eaffe11a138f4e41c
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
10 * Copyright (C) 2006 by Frank Dischner
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
19 #include "hangul.h"
21 const char jamo_table[51][3] = {
22 { 1, 0, 1},
23 { 2, 0, 2},
24 { 0, 0, 3},
25 { 3, 0, 4},
26 { 0, 0, 5},
27 { 0, 0, 6},
28 { 4, 0, 7},
29 { 5, 0, 0},
30 { 6, 0, 8},
31 { 0, 0, 9},
32 { 0, 0, 10},
33 { 0, 0, 11},
34 { 0, 0, 12},
35 { 0, 0, 13},
36 { 0, 0, 14},
37 { 0, 0, 15},
38 { 7, 0, 16},
39 { 8, 0, 17},
40 { 9, 0, 0},
41 { 0, 0, 18},
42 {10, 0, 19},
43 {11, 0, 20},
44 {12, 0, 21},
45 {13, 0, 22},
46 {14, 0, 0},
47 {15, 0, 23},
48 {16, 0, 24},
49 {17, 0, 25},
50 {18, 0, 26},
51 {19, 0, 27},
52 { 0, 1, 0},
53 { 0, 2, 0},
54 { 0, 3, 0},
55 { 0, 4, 0},
56 { 0, 5, 0},
57 { 0, 6, 0},
58 { 0, 7, 0},
59 { 0, 8, 0},
60 { 0, 9, 0},
61 { 0, 10, 0},
62 { 0, 11, 0},
63 { 0, 12, 0},
64 { 0, 13, 0},
65 { 0, 14, 0},
66 { 0, 15, 0},
67 { 0, 16, 0},
68 { 0, 17, 0},
69 { 0, 18, 0},
70 { 0, 19, 0},
71 { 0, 20, 0},
72 { 0, 21, 0},
75 /* takes three jamo chars and joins them into one hangul */
76 unsigned short hangul_join(unsigned short lead, unsigned short vowel,
77 unsigned short tail)
79 unsigned short ch = 0xfffd;
81 if (lead < 0x3131 || lead > 0x3163)
82 return ch;
83 lead = jamo_table[lead-0x3131][0];
85 if (vowel < 0x3131 || vowel > 0x3163)
86 return ch;
87 vowel = jamo_table[vowel-0x3131][1];
89 if (tail) {
90 if (tail < 0x3131 || tail > 0x3163)
91 return ch;
92 tail = jamo_table[tail-0x3131][2];
93 if (!tail)
94 return ch;
97 if (lead && vowel)
98 ch = tail + (vowel - 1)*28 + (lead - 1)*588 + 44032;
100 return ch;