A modern Music Player Daemon based on Rockbox open source high quality audio player
libadwaita audio rust zig deno mpris rockbox mpd
at master 103 lines 2.6 kB view raw
1/*************************************************************************** 2 * __________ __ ___. 3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___ 4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ / 5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < 6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ 7 * \/ \/ \/ \/ \/ 8 * 9 * 10 * Copyright (C) 2006 by Frank Dischner 11 * 12 * This program is free software; you can redistribute it and/or 13 * modify it under the terms of the GNU General Public License 14 * as published by the Free Software Foundation; either version 2 15 * of the License, or (at your option) any later version. 16 * 17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 18 * KIND, either express or implied. 19 * 20 ****************************************************************************/ 21#include "config.h" 22#include "hangul.h" 23 24const char jamo_table[51][3] = { 25 { 1, 0, 1}, 26 { 2, 0, 2}, 27 { 0, 0, 3}, 28 { 3, 0, 4}, 29 { 0, 0, 5}, 30 { 0, 0, 6}, 31 { 4, 0, 7}, 32 { 5, 0, 0}, 33 { 6, 0, 8}, 34 { 0, 0, 9}, 35 { 0, 0, 10}, 36 { 0, 0, 11}, 37 { 0, 0, 12}, 38 { 0, 0, 13}, 39 { 0, 0, 14}, 40 { 0, 0, 15}, 41 { 7, 0, 16}, 42 { 8, 0, 17}, 43 { 9, 0, 0}, 44 { 0, 0, 18}, 45 {10, 0, 19}, 46 {11, 0, 20}, 47 {12, 0, 21}, 48 {13, 0, 22}, 49 {14, 0, 0}, 50 {15, 0, 23}, 51 {16, 0, 24}, 52 {17, 0, 25}, 53 {18, 0, 26}, 54 {19, 0, 27}, 55 { 0, 1, 0}, 56 { 0, 2, 0}, 57 { 0, 3, 0}, 58 { 0, 4, 0}, 59 { 0, 5, 0}, 60 { 0, 6, 0}, 61 { 0, 7, 0}, 62 { 0, 8, 0}, 63 { 0, 9, 0}, 64 { 0, 10, 0}, 65 { 0, 11, 0}, 66 { 0, 12, 0}, 67 { 0, 13, 0}, 68 { 0, 14, 0}, 69 { 0, 15, 0}, 70 { 0, 16, 0}, 71 { 0, 17, 0}, 72 { 0, 18, 0}, 73 { 0, 19, 0}, 74 { 0, 20, 0}, 75 { 0, 21, 0}, 76}; 77 78/* takes three jamo chars and joins them into one hangul */ 79ucschar_t hangul_join(ucschar_t lead, ucschar_t vowel, ucschar_t tail) 80{ 81 ucschar_t ch = 0xfffd; 82 83 if (lead < 0x3131 || lead > 0x3163) 84 return ch; 85 lead = jamo_table[lead-0x3131][0]; 86 87 if (vowel < 0x3131 || vowel > 0x3163) 88 return ch; 89 vowel = jamo_table[vowel-0x3131][1]; 90 91 if (tail) { 92 if (tail < 0x3131 || tail > 0x3163) 93 return ch; 94 tail = jamo_table[tail-0x3131][2]; 95 if (!tail) 96 return ch; 97 } 98 99 if (lead && vowel) 100 ch = tail + (vowel - 1)*28 + (lead - 1)*588 + 44032; 101 102 return ch; 103}