1 /* This file is part of the YAZ toolkit.
2 * Copyright (C) 1995-2008 Index Data
3 * See the file LICENSE for details.
7 * \brief ISO-5428:1984 encoding and decoding
21 unsigned long yaz_read_iso5428_1984(yaz_iconv_t cd, unsigned char *inp,
22 size_t inbytesleft, size_t *no_read)
29 while (inbytesleft > 0)
35 else if (*inp == 0xa3)
47 yaz_iconv_set_errno(cd, YAZ_ICONV_EINVAL); /* incomplete input */
52 case 0xe1: /* alpha small */
58 case 0xc1: /* alpha capital */
65 case 0xe2: /* Beta small */
68 case 0xc2: /* Beta capital */
72 case 0xe4: /* Gamma small */
75 case 0xc4: /* Gamma capital */
79 case 0xe5: /* Delta small */
82 case 0xc5: /* Delta capital */
85 case 0xe6: /* epsilon small */
91 case 0xc6: /* epsilon capital */
97 case 0xe9: /* Zeta small */
100 case 0xc9: /* Zeta capital */
103 case 0xea: /* Eta small */
109 case 0xca: /* Eta capital */
115 case 0xeb: /* Theta small */
118 case 0xcb: /* Theta capital */
121 case 0xec: /* Iota small */
133 case 0xcc: /* Iota capital */
142 case 0xed: /* Kappa small */
145 case 0xcd: /* Kappa capital */
148 case 0xee: /* Lambda small */
151 case 0xce: /* Lambda capital */
154 case 0xef: /* Mu small */
157 case 0xcf: /* Mu capital */
160 case 0xf0: /* Nu small */
163 case 0xd0: /* Nu capital */
166 case 0xf1: /* Xi small */
169 case 0xd1: /* Xi capital */
172 case 0xf2: /* Omicron small */
178 case 0xd2: /* Omicron capital */
184 case 0xf3: /* Pi small */
187 case 0xd3: /* Pi capital */
190 case 0xf5: /* Rho small */
193 case 0xd5: /* Rho capital */
196 case 0xf7: /* Sigma small (end of words) */
199 case 0xf6: /* Sigma small */
202 case 0xd6: /* Sigma capital */
205 case 0xf8: /* Tau small */
208 case 0xd8: /* Tau capital */
211 case 0xf9: /* Upsilon small */
223 case 0xd9: /* Upsilon capital */
232 case 0xfa: /* Phi small */
235 case 0xda: /* Phi capital */
238 case 0xfb: /* Chi small */
241 case 0xdb: /* Chi capital */
244 case 0xfc: /* Psi small */
247 case 0xdc: /* Psi capital */
250 case 0xfd: /* Omega small */
256 case 0xdd: /* Omega capital */
271 static size_t write_iso_5428_1984(yaz_iconv_t cd, yaz_iconv_encoder_t en,
273 char **outbuf, size_t *outbytesleft)
276 unsigned char *out = (unsigned char*) *outbuf;
277 if (*outbytesleft < 3)
279 yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG); /* not room for output */
284 case 0x03ac : out[k++]=0xa2; out[k++]=0xe1; break;
285 case 0x03b1 : out[k++]=0xe1; break;
286 case 0x0386 : out[k++]=0xa2; out[k++]=0xc1; break;
287 case 0x0391 : out[k++]=0xc1; break;
288 case 0x03b2 : out[k++]=0xe2; break;
289 case 0x0392 : out[k++]=0xc2; break;
290 case 0x03b3 : out[k++]=0xe4; break;
291 case 0x0393 : out[k++]=0xc4; break;
292 case 0x03b4 : out[k++]=0xe5; break;
293 case 0x0394 : out[k++]=0xc5; break;
294 case 0x03ad : out[k++]=0xa2; out[k++]=0xe6; break;
295 case 0x03b5 : out[k++]=0xe6; break;
296 case 0x0388 : out[k++]=0xa2; out[k++]=0xc6; break;
297 case 0x0395 : out[k++]=0xc6; break;
298 case 0x03b6 : out[k++]=0xe9; break;
299 case 0x0396 : out[k++]=0xc9; break;
300 case 0x03ae : out[k++]=0xa2; out[k++]=0xea; break;
301 case 0x03b7 : out[k++]=0xea; break;
302 case 0x0389 : out[k++]=0xa2; out[k++]=0xca; break;
303 case 0x0397 : out[k++]=0xca; break;
304 case 0x03b8 : out[k++]=0xeb; break;
305 case 0x0398 : out[k++]=0xcb; break;
306 case 0x0390 : out[k++]=0xa2; out[k++]=0xa3; out[k++]=0xec; break;
307 case 0x03af : out[k++]=0xa2; out[k++]=0xec; break;
308 case 0x03ca : out[k++]=0xa3; out[k++]=0xec; break;
309 case 0x03b9 : out[k++]=0xec; break;
310 case 0x038a : out[k++]=0xa2; out[k++]=0xcc; break;
311 case 0x03aa : out[k++]=0xa3; out[k++]=0xcc; break;
312 case 0x0399 : out[k++]=0xcc; break;
313 case 0x03ba : out[k++]=0xed; break;
314 case 0x039a : out[k++]=0xcd; break;
315 case 0x03bb : out[k++]=0xee; break;
316 case 0x039b : out[k++]=0xce; break;
317 case 0x03bc : out[k++]=0xef; break;
318 case 0x039c : out[k++]=0xcf; break;
319 case 0x03bd : out[k++]=0xf0; break;
320 case 0x039d : out[k++]=0xd0; break;
321 case 0x03be : out[k++]=0xf1; break;
322 case 0x039e : out[k++]=0xd1; break;
323 case 0x03cc : out[k++]=0xa2; out[k++]=0xf2; break;
324 case 0x03bf : out[k++]=0xf2; break;
325 case 0x038c : out[k++]=0xa2; out[k++]=0xd2; break;
326 case 0x039f : out[k++]=0xd2; break;
327 case 0x03c0 : out[k++]=0xf3; break;
328 case 0x03a0 : out[k++]=0xd3; break;
329 case 0x03c1 : out[k++]=0xf5; break;
330 case 0x03a1 : out[k++]=0xd5; break;
331 case 0x03c2 : out[k++]=0xf7; break;
332 case 0x03c3 : out[k++]=0xf6; break;
333 case 0x03a3 : out[k++]=0xd6; break;
334 case 0x03c4 : out[k++]=0xf8; break;
335 case 0x03a4 : out[k++]=0xd8; break;
336 case 0x03b0 : out[k++]=0xa2; out[k++]=0xa3; out[k++]=0xf9; break;
337 case 0x03cd : out[k++]=0xa2; out[k++]=0xf9; break;
338 case 0x03cb : out[k++]=0xa3; out[k++]=0xf9; break;
339 case 0x03c5 : out[k++]=0xf9; break;
340 case 0x038e : out[k++]=0xa2; out[k++]=0xd9; break;
341 case 0x03ab : out[k++]=0xa3; out[k++]=0xd9; break;
342 case 0x03a5 : out[k++]=0xd9; break;
343 case 0x03c6 : out[k++]=0xfa; break;
344 case 0x03a6 : out[k++]=0xda; break;
345 case 0x03c7 : out[k++]=0xfb; break;
346 case 0x03a7 : out[k++]=0xdb; break;
347 case 0x03c8 : out[k++]=0xfc; break;
348 case 0x03a8 : out[k++]=0xdc; break;
349 case 0x03ce : out[k++]=0xa2; out[k++]=0xfd; break;
350 case 0x03c9 : out[k++]=0xfd; break;
351 case 0x038f : out[k++]=0xa2; out[k++]=0xdd; break;
352 case 0x03a9 : out[k++]=0xdd; break;
356 yaz_iconv_set_errno(cd, YAZ_ICONV_EILSEQ);
367 yaz_iconv_encoder_t yaz_iso_5428_encoder(const char *name,
368 yaz_iconv_encoder_t e)
370 if (!yaz_matchstr(name, "iso54281984")
371 || !yaz_matchstr(name, "iso5428:1984"))
373 e->write_handle = write_iso_5428_1984;
383 * indent-tabs-mode: nil
385 * vim: shiftwidth=4 tabstop=8 expandtab