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 Advance Greek encoding and decoding
21 unsigned long yaz_read_advancegreek(yaz_iconv_t cd, unsigned char *inp,
22 size_t inbytesleft, size_t *no_read)
30 while (inbytesleft > 0)
36 else if (*inp == 0x9e)
40 else if (*inp == 0x9f)
52 yaz_iconv_set_errno(cd, YAZ_ICONV_EINVAL); /* incomplete input */
280 static size_t write_advancegreek(yaz_iconv_t cd, yaz_iconv_encoder_t w,
282 char **outbuf, size_t *outbytesleft)
285 unsigned char *out = (unsigned char*) *outbuf;
286 if (*outbytesleft < 3)
288 yaz_iconv_set_errno(cd, YAZ_ICONV_E2BIG); /* not room for output */
293 case 0x03ac : out[k++]=0x9d; out[k++]=0x81; break;
294 case 0x03ad : out[k++]=0x9d; out[k++]=0x85; break;
295 case 0x03ae : out[k++]=0x9d; out[k++]=0x87; break;
296 case 0x03af : out[k++]=0x9d; out[k++]=0x89; break;
297 case 0x03cc : out[k++]=0x9d; out[k++]=0x8f; break;
298 case 0x03cd : out[k++]=0x9d; out[k++]=0x95; break;
299 case 0x03ce : out[k++]=0x9d; out[k++]=0x99; break;
300 case 0x0390 : out[k++]=0x9d; out[k++]=0x9e; out[k++]=0x89; break;
301 case 0x03b0 : out[k++]=0x9d; out[k++]=0x9e; out[k++]=0x95; break;
302 case 0x0386 : out[k++]=0x9d; out[k++]=0x9f; out[k++]=0x81; break;
303 case 0x0388 : out[k++]=0x9d; out[k++]=0x9f; out[k++]=0x85; break;
304 case 0x0389 : out[k++]=0x9d; out[k++]=0x9f; out[k++]=0x87; break;
305 case 0x038a : out[k++]=0x9d; out[k++]=0x9f; out[k++]=0x89; break;
306 case 0x038c : out[k++]=0x9d; out[k++]=0x9f; out[k++]=0x8f; break;
307 case 0x038e : out[k++]=0x9d; out[k++]=0x9f; out[k++]=0x95; break;
308 case 0x038f : out[k++]=0x9d; out[k++]=0x9f; out[k++]=0x99; break;
309 case 0x03ca : out[k++]=0x9e; out[k++]=0x89; break;
310 case 0x03cb : out[k++]=0x9e; out[k++]=0x95; break;
311 case 0x03aa : out[k++]=0x9e; out[k++]=0x9f; out[k++]=0x89; break;
312 case 0x03ab : out[k++]=0x9e; out[k++]=0x9f; out[k++]=0x95; break;
313 case 0x0391 : out[k++]=0x9f; out[k++]=0x81; break;
314 case 0x0392 : out[k++]=0x9f; out[k++]=0x82; break;
315 case 0x0393 : out[k++]=0x9f; out[k++]=0x83; break;
316 case 0x0394 : out[k++]=0x9f; out[k++]=0x84; break;
317 case 0x0395 : out[k++]=0x9f; out[k++]=0x85; break;
318 case 0x0396 : out[k++]=0x9f; out[k++]=0x86; break;
319 case 0x0397 : out[k++]=0x9f; out[k++]=0x87; break;
320 case 0x0398 : out[k++]=0x9f; out[k++]=0x88; break;
321 case 0x0399 : out[k++]=0x9f; out[k++]=0x89; break;
322 case 0x039a : out[k++]=0x9f; out[k++]=0x8a; break;
323 case 0x039b : out[k++]=0x9f; out[k++]=0x8b; break;
324 case 0x039c : out[k++]=0x9f; out[k++]=0x8c; break;
325 case 0x039d : out[k++]=0x9f; out[k++]=0x8d; break;
326 case 0x039e : out[k++]=0x9f; out[k++]=0x8e; break;
327 case 0x039f : out[k++]=0x9f; out[k++]=0x8f; break;
328 case 0x03a0 : out[k++]=0x9f; out[k++]=0x90; break;
329 case 0x03a1 : out[k++]=0x9f; out[k++]=0x91; break;
330 case 0x03a3 : out[k++]=0x9f; out[k++]=0x93; break;
331 case 0x03a4 : out[k++]=0x9f; out[k++]=0x94; break;
332 case 0x03a5 : out[k++]=0x9f; out[k++]=0x95; break;
333 case 0x03a6 : out[k++]=0x9f; out[k++]=0x96; break;
334 case 0x03a7 : out[k++]=0x9f; out[k++]=0x97; break;
335 case 0x03a8 : out[k++]=0x9f; out[k++]=0x98; break;
336 case 0x03a9 : out[k++]=0x9f; out[k++]=0x99; break;
337 case 0x03b1 : out[k++]=0x81; break;
338 case 0x03b2 : out[k++]=0x82; break;
339 case 0x03b3 : out[k++]=0x83; break;
340 case 0x03b4 : out[k++]=0x84; break;
341 case 0x03b5 : out[k++]=0x85; break;
342 case 0x03b6 : out[k++]=0x86; break;
343 case 0x03b7 : out[k++]=0x87; break;
344 case 0x03b8 : out[k++]=0x88; break;
345 case 0x03b9 : out[k++]=0x89; break;
346 case 0x03ba : out[k++]=0x8a; break;
347 case 0x03bb : out[k++]=0x8b; break;
348 case 0x03bc : out[k++]=0x8c; break;
349 case 0x03bd : out[k++]=0x8d; break;
350 case 0x03be : out[k++]=0x8e; break;
351 case 0x03bf : out[k++]=0x8f; break;
352 case 0x03c0 : out[k++]=0x90; break;
353 case 0x03c1 : out[k++]=0x91; break;
354 case 0x03c2 : out[k++]=0x92; break;
355 case 0x03c3 : out[k++]=0x93; break;
356 case 0x03c4 : out[k++]=0x94; break;
357 case 0x03c5 : out[k++]=0x95; break;
358 case 0x03c6 : out[k++]=0x96; break;
359 case 0x03c7 : out[k++]=0x96; break;
360 case 0x03c8 : out[k++]=0x98; break;
361 case 0x03c9 : out[k++]=0x99; break;
365 yaz_iconv_set_errno(cd, YAZ_ICONV_EILSEQ);
376 yaz_iconv_encoder_t yaz_advancegreek_encoder(const char *name,
377 yaz_iconv_encoder_t e)
379 if (!yaz_matchstr(name, "advancegreek"))
381 e->write_handle = write_advancegreek;
390 * indent-tabs-mode: nil
392 * vim: shiftwidth=4 tabstop=8 expandtab