/*
- * Copyright (C) 1995-2006, Index Data ApS
+ * Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: siconv.c,v 1.28 2006-08-30 20:14:51 adam Exp $
+ * $Id: siconv.c,v 1.32 2007-01-03 08:42:15 adam Exp $
*/
/**
* \file siconv.c
unsigned long write_marc8_comb_ch[8];
size_t write_marc8_comb_no;
+ unsigned write_marc8_second_half_char;
unsigned long write_marc8_last;
const char *write_marc8_page_chr;
};
return x;
}
-static size_t yaz_init_marc8(yaz_iconv_t cd, unsigned char *inp,
- size_t inbytesleft, size_t *no_read)
-{
- cd->marc8_esc_mode = 'B';
-
- cd->comb_offset = cd->comb_size = 0;
- cd->compose_char = 0;
-
- cd->write_marc8_comb_no = 0;
- cd->write_marc8_last = 0;
- cd->write_marc8_page_chr = "\033(B";
-
- return 0;
-}
static size_t yaz_init_UTF8 (yaz_iconv_t cd, unsigned char *inp,
size_t inbytesleft, size_t *no_read)
size_t inbytesleft0 = inbytesleft;
inp++;
inbytesleft--;
- while(inbytesleft > 0 && strchr("(,$!", *inp))
+ while(inbytesleft > 0 && strchr("(,$!)-", *inp))
{
inbytesleft--;
inp++;
char **outbuf, size_t *outbytesleft)
{
unsigned long y = cd->write_marc8_last;
- unsigned char byte, second_half = 0;
+ unsigned char byte;
char out_buf[10];
size_t i, out_no = 0;
{
/* all MARC-8 combined characters are simple bytes */
byte = (unsigned char )(cd->write_marc8_comb_ch[i]);
- if (byte == 0xEB)
- second_half = 0xEC;
- else if (byte == 0xFA)
- second_half = 0xFB;
-
*(*outbuf)++ = byte;
(*outbytesleft)--;
}
memcpy(*outbuf, out_buf, out_no);
*outbuf += out_no;
(*outbytesleft) -= out_no;
- if (second_half)
+ if (cd->write_marc8_second_half_char)
{
- *(*outbuf)++ = second_half;
+ *(*outbuf)++ = cd->write_marc8_second_half_char;
(*outbytesleft)--;
}
cd->write_marc8_last = 0;
cd->write_marc8_comb_no = 0;
+ cd->write_marc8_second_half_char = 0;
return 0;
}
if (comb)
{
+ if (x == 0x0361)
+ cd->write_marc8_second_half_char = 0xEC;
+ else if (x == 0x0360)
+ cd->write_marc8_second_half_char = 0xFB;
+
if (cd->write_marc8_comb_no < 6)
cd->write_marc8_comb_ch[cd->write_marc8_comb_no++] = y;
}
else if (!yaz_matchstr(fromcode, "UCS4LE"))
cd->read_handle = yaz_read_UCS4LE;
else if (!yaz_matchstr(fromcode, "MARC8"))
- {
cd->read_handle = yaz_read_marc8;
- cd->init_handle = yaz_init_marc8;
- }
else if (!yaz_matchstr(fromcode, "MARC8s"))
- {
cd->read_handle = yaz_read_marc8s;
- cd->init_handle = yaz_init_marc8;
- }
#if HAVE_WCHAR_H
else if (!yaz_matchstr(fromcode, "WCHAR_T"))
cd->read_handle = yaz_read_wchar_t;
else if (!yaz_matchstr(tocode, "UCS4LE"))
cd->write_handle = yaz_write_UCS4LE;
else if (!yaz_matchstr(tocode, "MARC8"))
- {
cd->write_handle = yaz_write_marc8;
- cd->init_handle = yaz_init_marc8;
- }
else if (!yaz_matchstr(tocode, "MARC8s"))
- {
cd->write_handle = yaz_write_marc8;
- cd->init_handle = yaz_init_marc8;
- }
#if HAVE_WCHAR_H
else if (!yaz_matchstr(tocode, "WCHAR_T"))
cd->write_handle = yaz_write_wchar_t;
*inbytesleft -= no_read;
*inbuf += no_read;
}
+ cd->marc8_esc_mode = 'B';
+
+ cd->comb_offset = cd->comb_size = 0;
+ cd->compose_char = 0;
+
+ cd->write_marc8_comb_no = 0;
+ cd->write_marc8_second_half_char = 0;
+ cd->write_marc8_last = 0;
+ cd->write_marc8_page_chr = "\033(B";
+
cd->init_flag = 0;
cd->unget_x = 0;
cd->no_read_x = 0;