1 /*
2 encoding data and routines dependent on language; slovak
3
4 Copyright (C) 2000-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/slovak/slovak.h"
26
27 /* Local prototypes. */
28 static int hook(EncaAnalyserState *analyser);
29 static int eol_hook(EncaAnalyserState *analyser);
30 static int hook_iso1250(EncaAnalyserState *analyser);
31 static int hook_ibmkam(EncaAnalyserState *analyser);
32 static int hook_isowin(EncaAnalyserState *analyser);
33
34 /**
35 * ENCA_LANGUAGE_SK:
36 *
37 * Slovak language.
38 *
39 * Everything the world out there needs to know about this language.
40 **/
41 const EncaLanguageInfo ENCA_LANGUAGE_SK = {
42 "sk",
43 "slovak",
44 NCHARSETS,
45 CHARSET_NAMES,
46 CHARSET_WEIGHTS,
47 SIGNIFICANT,
48 CHARSET_LETTERS,
49 CHARSET_PAIRS,
50 WEIGHT_SUM,
51 &hook,
52 &eol_hook,
53 NULL,
54 NULL
55 };
56
57 /**
58 * hook:
59 * @analyser: Analyser state whose charset ratings are to be modified.
60 *
61 * Launches language specific hooks for language "sk".
62 *
63 * Returns: Nonzero if charset ratigns have been actually modified, zero
64 * otherwise.
65 **/
66 static int
hook(EncaAnalyserState * analyser)67 hook(EncaAnalyserState *analyser)
68 {
69 return hook_iso1250(analyser)
70 || hook_ibmkam(analyser);
71 }
72
73 /**
74 * eol_hook:
75 * @analyser: Analyser state whose charset ratings are to be modified.
76 *
77 * Launches language specific EOL hooks for language "sk".
78 *
79 * Returns: Nonzero if charset ratigns have been actually modified, zero
80 * otherwise.
81 **/
82 static int
eol_hook(EncaAnalyserState * analyser)83 eol_hook(EncaAnalyserState *analyser)
84 {
85 return hook_isowin(analyser);
86 }
87
88 /**
89 * hook_isowin:
90 * @analyser: Analyser state whose charset ratings are to be modified.
91 *
92 * Decides between iso8859-2 and cp1250 charsets for language "sk".
93 *
94 * Returns: Nonzero if charset ratigns have been actually modified, zero
95 * otherwise.
96 **/
97 static int
hook_isowin(EncaAnalyserState * analyser)98 hook_isowin(EncaAnalyserState *analyser)
99 {
100 static EncaLanguageHookDataEOL hookdata[] = {
101 { "cp1250", ENCA_SURFACE_EOL_CRLF, (size_t)-1 },
102 { "iso88592", ENCA_SURFACE_MASK_EOL, (size_t)-1 },
103 };
104
105 return enca_language_hook_eol(analyser, ELEMENTS(hookdata), hookdata);
106 }
107
108 /**
109 * hook_iso1250:
110 * @analyser: Analyser state whose charset ratings are to be modified.
111 *
112 * Decides between iso8859-2 and cp1250 charsets for language "sk".
113 *
114 * Returns: Nonzero if charset ratigns have been actually modified, zero
115 * otherwise.
116 **/
117 static int
hook_iso1250(EncaAnalyserState * analyser)118 hook_iso1250(EncaAnalyserState *analyser)
119 {
120 static const unsigned char list_iso88592[] = {
121 0xb9, 0xbb, 0xb5, 0xa9, 0xae
122 };
123 static const unsigned char list_cp1250[] = {
124 0x9e, 0x9a, 0x9d, 0x8a, 0x8e
125 };
126 static EncaLanguageHookData1CS hookdata[] = {
127 MAKE_HOOK_LINE(iso88592),
128 MAKE_HOOK_LINE(cp1250),
129 };
130
131 return enca_language_hook_ncs(analyser, ELEMENTS(hookdata), hookdata);
132 }
133
134 /**
135 * hook_ibmkam:
136 * @analyser: Analyser state whose charset ratings are to be modified.
137 *
138 * Decides between ibm852 and keybcs2 charsets for language "sk".
139 *
140 * Returns: Nonzero if charset ratigns have been actually modified, zero
141 * otherwise.
142 **/
143 static int
hook_ibmkam(EncaAnalyserState * analyser)144 hook_ibmkam(EncaAnalyserState *analyser)
145 {
146 static const unsigned char list_ibm852[] = {
147 0xa7, 0xe7, 0xec, 0x9c, 0x96, 0xd4, 0xe5
148 };
149 static const unsigned char list_keybcs2[] = {
150 0x87, 0x91, 0xa8, 0x98, 0x8c, 0x83, 0xa4
151 };
152 static EncaLanguageHookData1CS hookdata[] = {
153 MAKE_HOOK_LINE(ibm852),
154 MAKE_HOOK_LINE(keybcs2),
155 };
156
157 return enca_language_hook_ncs(analyser, ELEMENTS(hookdata), hookdata);
158 }
159
160 /* vim: ts=2
161 */
162