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 static unsigned long read_iso_5428_1984(yaz_iconv_t cd, yaz_iconv_decoder_t d,
23 size_t inbytesleft, size_t *no_read)
30 while (inbytesleft > 0)
36 else if (*inp == 0xa3)
48 yaz_iconv_set_errno(cd, YAZ_ICONV_EINVAL); /* incomplete input */
53 case 0xe1: /* alpha small */
59 case 0xc1: /* alpha capital */
66 case 0xe2: /* Beta small */
69 case 0xc2: /* Beta capital */
73 case 0xe4: /* Gamma small */
76 case 0xc4: /* Gamma capital */
80 case 0xe5: /* Delta small */
83 case 0xc5: /* Delta capital */
86 case 0xe6: /* epsilon small */
92 case 0xc6: /* epsilon capital */
98 case 0xe9: /* Zeta small */
101 case 0xc9: /* Zeta capital */
104 case 0xea: /* Eta small */
110 case 0xca: /* Eta capital */
116 case 0xeb: /* Theta small */
119 case 0xcb: /* Theta capital */
122 case 0xec: /* Iota small */
134 case 0xcc: /* Iota capital */
143 case 0xed: /* Kappa small */
146 case 0xcd: /* Kappa capital */
149 case 0xee: /* Lambda small */
152 case 0xce: /* Lambda capital */
155 case 0xef: /* Mu small */
158 case 0xcf: /* Mu capital */
161 case 0xf0: /* Nu small */
164 case 0xd0: /* Nu capital */
167 case 0xf1: /* Xi small */
170 case 0xd1: /* Xi capital */
173 case 0xf2: /* Omicron small */
179 case 0xd2: /* Omicron capital */
185 case 0xf3: /* Pi small */
188 case 0xd3: /* Pi capital */
191 case 0xf5: /* Rho small */
194 case 0xd5: /* Rho capital */
197 case 0xf7: /* Sigma small (end of words) */
200 case 0xf6: /* Sigma small */
203 case 0xd6: /* Sigma capital */
206 case 0xf8: /* Tau small */
209 case 0xd8: /* Tau capital */
212 case 0xf9: /* Upsilon small */
224 case 0xd9: /* Upsilon capital */
233 case 0xfa: /* Phi small */
236 case 0xda: /* Phi capital */
239 case 0xfb: /* Chi small */
242 case 0xdb: /* Chi capital */
245 case 0xfc: /* Psi small */
248 case 0xdc: /* Psi capital */
251 case 0xfd: /* Omega small */
257 case 0xdd: /* Omega capital */
272 static size_t write_iso_5428_1984(yaz_iconv_t cd, yaz_iconv_encoder_t en,
274 char **outbuf, size_t *outbytesleft)
277 unsigned char *out = (unsigned char*) *outbuf;
278 if (*outbytesleft < 3)
280 yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG); /* not room for output */
285 case 0x03ac : out[k++]=0xa2; out[k++]=0xe1; break;
286 case 0x03b1 : out[k++]=0xe1; break;
287 case 0x0386 : out[k++]=0xa2; out[k++]=0xc1; break;
288 case 0x0391 : out[k++]=0xc1; break;
289 case 0x03b2 : out[k++]=0xe2; break;
290 case 0x0392 : out[k++]=0xc2; break;
291 case 0x03b3 : out[k++]=0xe4; break;
292 case 0x0393 : out[k++]=0xc4; break;
293 case 0x03b4 : out[k++]=0xe5; break;
294 case 0x0394 : out[k++]=0xc5; break;
295 case 0x03ad : out[k++]=0xa2; out[k++]=0xe6; break;
296 case 0x03b5 : out[k++]=0xe6; break;
297 case 0x0388 : out[k++]=0xa2; out[k++]=0xc6; break;
298 case 0x0395 : out[k++]=0xc6; break;
299 case 0x03b6 : out[k++]=0xe9; break;
300 case 0x0396 : out[k++]=0xc9; break;
301 case 0x03ae : out[k++]=0xa2; out[k++]=0xea; break;
302 case 0x03b7 : out[k++]=0xea; break;
303 case 0x0389 : out[k++]=0xa2; out[k++]=0xca; break;
304 case 0x0397 : out[k++]=0xca; break;
305 case 0x03b8 : out[k++]=0xeb; break;
306 case 0x0398 : out[k++]=0xcb; break;
307 case 0x0390 : out[k++]=0xa2; out[k++]=0xa3; out[k++]=0xec; break;
308 case 0x03af : out[k++]=0xa2; out[k++]=0xec; break;
309 case 0x03ca : out[k++]=0xa3; out[k++]=0xec; break;
310 case 0x03b9 : out[k++]=0xec; break;
311 case 0x038a : out[k++]=0xa2; out[k++]=0xcc; break;
312 case 0x03aa : out[k++]=0xa3; out[k++]=0xcc; break;
313 case 0x0399 : out[k++]=0xcc; break;
314 case 0x03ba : out[k++]=0xed; break;
315 case 0x039a : out[k++]=0xcd; break;
316 case 0x03bb : out[k++]=0xee; break;
317 case 0x039b : out[k++]=0xce; break;
318 case 0x03bc : out[k++]=0xef; break;
319 case 0x039c : out[k++]=0xcf; break;
320 case 0x03bd : out[k++]=0xf0; break;
321 case 0x039d : out[k++]=0xd0; break;
322 case 0x03be : out[k++]=0xf1; break;
323 case 0x039e : out[k++]=0xd1; break;
324 case 0x03cc : out[k++]=0xa2; out[k++]=0xf2; break;
325 case 0x03bf : out[k++]=0xf2; break;
326 case 0x038c : out[k++]=0xa2; out[k++]=0xd2; break;
327 case 0x039f : out[k++]=0xd2; break;
328 case 0x03c0 : out[k++]=0xf3; break;
329 case 0x03a0 : out[k++]=0xd3; break;
330 case 0x03c1 : out[k++]=0xf5; break;
331 case 0x03a1 : out[k++]=0xd5; break;
332 case 0x03c2 : out[k++]=0xf7; break;
333 case 0x03c3 : out[k++]=0xf6; break;
334 case 0x03a3 : out[k++]=0xd6; break;
335 case 0x03c4 : out[k++]=0xf8; break;
336 case 0x03a4 : out[k++]=0xd8; break;
337 case 0x03b0 : out[k++]=0xa2; out[k++]=0xa3; out[k++]=0xf9; break;
338 case 0x03cd : out[k++]=0xa2; out[k++]=0xf9; break;
339 case 0x03cb : out[k++]=0xa3; out[k++]=0xf9; break;
340 case 0x03c5 : out[k++]=0xf9; break;
341 case 0x038e : out[k++]=0xa2; out[k++]=0xd9; break;
342 case 0x03ab : out[k++]=0xa3; out[k++]=0xd9; break;
343 case 0x03a5 : out[k++]=0xd9; break;
344 case 0x03c6 : out[k++]=0xfa; break;
345 case 0x03a6 : out[k++]=0xda; break;
346 case 0x03c7 : out[k++]=0xfb; break;
347 case 0x03a7 : out[k++]=0xdb; break;
348 case 0x03c8 : out[k++]=0xfc; break;
349 case 0x03a8 : out[k++]=0xdc; break;
350 case 0x03ce : out[k++]=0xa2; out[k++]=0xfd; break;
351 case 0x03c9 : out[k++]=0xfd; break;
352 case 0x038f : out[k++]=0xa2; out[k++]=0xdd; break;
353 case 0x03a9 : out[k++]=0xdd; break;
357 yaz_iconv_set_errno(cd, YAZ_ICONV_EILSEQ);
368 yaz_iconv_encoder_t yaz_iso_5428_encoder(const char *name,
369 yaz_iconv_encoder_t e)
371 if (!yaz_matchstr(name, "iso54281984")
372 || !yaz_matchstr(name, "iso5428:1984"))
374 e->write_handle = write_iso_5428_1984;
380 yaz_iconv_decoder_t yaz_iso_5428_decoder(const char *name,
381 yaz_iconv_decoder_t d)
383 if (!yaz_matchstr(name, "iso54281984")
384 || !yaz_matchstr(name, "iso5428:1984"))
386 d->read_handle = read_iso_5428_1984;
397 * indent-tabs-mode: nil
399 * vim: shiftwidth=4 tabstop=8 expandtab