1 /*
2 encoding data and routines dependent on language; bulgarian
3
4 Copyright (C) 2003 David Necas (Yeti) <yeti@physics.muni.cz>
5
6 This program is free software; you can redistribute it and/or modify it
7 under the terms of version 2 of the GNU General Public License as published
8 by the Free Software Foundation.
9
10 This program is distributed in the hope that it will be useful, but WITHOUT
11 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13 more details.
14
15 You should have received a copy of the GNU General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
18 */
19 #ifdef HAVE_CONFIG_H
20 # include "config.h"
21 #endif /* HAVE_CONFIG_H */
22
23 #include "enca.h"
24 #include "internal.h"
25 #include "data/bulgarian/bulgarian.h"
26
27 /* Local prototypes. */
28 static int hook(EncaAnalyserState *analyser);
29 static int hook_1251mac(EncaAnalyserState *analyser);
30 static int hook_winmac(EncaAnalyserState *analyser);
31
32 /**
33 * ENCA_LANGUAGE_BG:
34 *
35 * Bulgarian language.
36 *
37 * Everything the world out there needs to know about this language.
38 **/
39 const EncaLanguageInfo ENCA_LANGUAGE_BG = {
40 "bg",
41 "bulgarian",
42 NCHARSETS,
43 CHARSET_NAMES,
44 CHARSET_WEIGHTS,
45 SIGNIFICANT,
46 CHARSET_LETTERS,
47 CHARSET_PAIRS,
48 WEIGHT_SUM,
49 &hook,
50 &hook_winmac,
51 NULL,
52 NULL
53 };
54
55 /**
56 * hook:
57 * @analyser: Analyser state whose charset ratings are to be modified.
58 *
59 * Launches language specific hooks for language "bg".
60 *
61 * Returns: Nonzero if charset ratigns have been actually modified, zero
62 * otherwise.
63 **/
64 static int
hook(EncaAnalyserState * analyser)65 hook(EncaAnalyserState *analyser)
66 {
67 return hook_1251mac(analyser);
68 }
69
70 /**
71 * hook_winmac:
72 * @analyser: Analyser state whose charset ratings are to be modified.
73 *
74 * Decides between cp1251 and maccyr charsets for language "bg".
75 *
76 * Returns: Nonzero if charset ratigns have been actually modified, zero
77 * otherwise.
78 **/
79 static int
hook_winmac(EncaAnalyserState * analyser)80 hook_winmac(EncaAnalyserState *analyser)
81 {
82 static EncaLanguageHookDataEOL hookdata[] = {
83 { "maccyr", ENCA_SURFACE_EOL_CR, (size_t)-1 },
84 { "cp1251", ENCA_SURFACE_MASK_EOL, (size_t)-1 },
85 };
86
87 return enca_language_hook_eol(analyser, ELEMENTS(hookdata), hookdata);
88 }
89
90 /**
91 * hook_1251mac:
92 * @analyser: Analyser state whose charset ratings are to be modified.
93 *
94 * Decides between cp1251 and maccyr charsets for language "bg".
95 *
96 * Returns: Nonzero if charset ratigns have been actually modified, zero
97 * otherwise.
98 **/
99 static int
hook_1251mac(EncaAnalyserState * analyser)100 hook_1251mac(EncaAnalyserState *analyser)
101 {
102 /* The characters. */
103 static const unsigned char list_cp1251[] = {
104 0xff, 0xcd, 0xd2, 0xc0, 0xd1, 0xc8, 0xcf, 0xc2
105 };
106 static const unsigned char list_maccyr[] = {
107 0xdf, 0x8d, 0x92, 0x80, 0x91, 0x88, 0x8f, 0x82
108 };
109 static EncaLanguageHookData1CS hookdata[] = {
110 MAKE_HOOK_LINE(cp1251),
111 MAKE_HOOK_LINE(maccyr),
112 };
113
114 return enca_language_hook_ncs(analyser, ELEMENTS(hookdata), hookdata);
115 }
116
117 /* vim: ts=2
118 */
119
120