168 |
const char *get_source_encoding (const char *lang) |
const char *get_source_encoding (const char *lang) |
169 |
{ |
{ |
170 |
int i; |
int i; |
171 |
|
const char *dot; |
172 |
|
|
173 |
if (!lang) |
if (!lang) |
174 |
return NULL; |
return NULL; |
175 |
|
|
176 |
|
dot = strchr (lang, '.'); |
177 |
|
if (dot) |
178 |
|
/* TODO: The FHS has the worst specification of what's |
179 |
|
* supposed to go after the dot here that I've ever seen. To |
180 |
|
* quote from version 2.1: |
181 |
|
* |
182 |
|
* "It is recommended that this be a numeric representation |
183 |
|
* if possible (ISO standards, especially), not include |
184 |
|
* additional punctuation symbols, and that any letters be |
185 |
|
* in lowercase." |
186 |
|
* |
187 |
|
* Any sane standard would use directory names like |
188 |
|
* de_DE.ISO-8859-1; the examples in the FHS recommend |
189 |
|
* de_DE.88591 instead. Considering that there is no other |
190 |
|
* conceivable use for encodings in directory names other |
191 |
|
* than to pass them to iconv or similar, this is quite |
192 |
|
* startlingly useless. |
193 |
|
* |
194 |
|
* My plan is to ignore the current FHS specification on the |
195 |
|
* grounds that it's obviously wrong, and petition to have |
196 |
|
* it changed. |
197 |
|
*/ |
198 |
|
/* TODO: I should probably drop any ,<version> components. */ |
199 |
|
return dot + 1; |
200 |
|
|
201 |
for (i = 0; directory_table[i].lang_dir; ++i) { |
for (i = 0; directory_table[i].lang_dir; ++i) { |
202 |
if (STRNEQ (directory_table[i].lang_dir, lang, |
if (STRNEQ (directory_table[i].lang_dir, lang, |
203 |
strlen (directory_table[i].lang_dir))) |
strlen (directory_table[i].lang_dir))) |