diff options
Diffstat (limited to 'firmware')
-rw-r--r-- | firmware/SOURCES | 1 | ||||
-rw-r--r-- | firmware/export/hangul.h | 23 | ||||
-rw-r--r-- | firmware/hangul.c | 101 |
3 files changed, 125 insertions, 0 deletions
diff --git a/firmware/SOURCES b/firmware/SOURCES index 3dbe1e12b9..d145176145 100644 --- a/firmware/SOURCES +++ b/firmware/SOURCES | |||
@@ -63,6 +63,7 @@ drivers/lcd-player.c | |||
63 | #ifdef HAVE_LCD_BITMAP | 63 | #ifdef HAVE_LCD_BITMAP |
64 | arabjoin.c | 64 | arabjoin.c |
65 | bidi.c | 65 | bidi.c |
66 | hangul.c | ||
66 | #if LCD_DEPTH == 1 | 67 | #if LCD_DEPTH == 1 |
67 | drivers/lcd-recorder.c | 68 | drivers/lcd-recorder.c |
68 | #elif LCD_DEPTH == 2 | 69 | #elif LCD_DEPTH == 2 |
diff --git a/firmware/export/hangul.h b/firmware/export/hangul.h new file mode 100644 index 0000000000..d5f8b0636c --- /dev/null +++ b/firmware/export/hangul.h | |||
@@ -0,0 +1,23 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * | ||
10 | * Copyright (C) 2006 by Frank Dischner | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | |||
20 | extern const char jamo_table[51][3]; | ||
21 | |||
22 | unsigned short hangul_join(unsigned short lead, unsigned short vowel, | ||
23 | unsigned short tail); | ||
diff --git a/firmware/hangul.c b/firmware/hangul.c new file mode 100644 index 0000000000..27123ccb64 --- /dev/null +++ b/firmware/hangul.c | |||
@@ -0,0 +1,101 @@ | |||
1 | /*************************************************************************** | ||
2 | * __________ __ ___. | ||
3 | * Open \______ \ ____ ____ | | _\_ |__ _______ ___ | ||
4 | * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / | ||
5 | * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < | ||
6 | * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ | ||
7 | * \/ \/ \/ \/ \/ | ||
8 | * | ||
9 | * | ||
10 | * Copyright (C) 2006 by Frank Dischner | ||
11 | * | ||
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. | ||
14 | * | ||
15 | * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY | ||
16 | * KIND, either express or implied. | ||
17 | * | ||
18 | ****************************************************************************/ | ||
19 | #include "hangul.h" | ||
20 | |||
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}, | ||
73 | }; | ||
74 | |||
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) | ||
78 | { | ||
79 | unsigned short ch = 0xfffd; | ||
80 | |||
81 | if (lead < 0x3131 || lead > 0x3163) | ||
82 | return ch; | ||
83 | lead = jamo_table[lead-0x3131][0]; | ||
84 | |||
85 | if (vowel < 0x3131 || vowel > 0x3163) | ||
86 | return ch; | ||
87 | vowel = jamo_table[vowel-0x3131][1]; | ||
88 | |||
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; | ||
95 | } | ||
96 | |||
97 | if (lead && vowel) | ||
98 | ch = tail + (vowel - 1)*28 + (lead - 1)*588 + 44032; | ||
99 | |||
100 | return ch; | ||
101 | } | ||