* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: siconv.c,v 1.48 2007-10-15 20:45:05 adam Exp $
+ * $Id: siconv.c,v 1.49 2008-03-05 21:21:22 adam Exp $
*/
/**
* \file siconv.c
char **outbuf, size_t *outbytesleft);
size_t (*flush_handle)(yaz_iconv_t cd,
char **outbuf, size_t *outbytesleft);
- int marc8_esc_mode;
+ int g0_mode;
+ int g1_mode;
int comb_offset;
int comb_size;
*no_read = 0;
while(inbytesleft >= 1 && inp[0] == 27)
{
+ int ch;
size_t inbytesleft0 = inbytesleft;
inp++;
inbytesleft--;
- while(inbytesleft > 0 && strchr("(,$!)-", *inp))
+ if (inbytesleft > 0 && *inp == '$')
{
inbytesleft--;
inp++;
}
- if (inbytesleft <= 0)
+ if (inbytesleft <= 1)
{
*no_read = 0;
cd->my_errno = YAZ_ICONV_EINVAL;
return 0;
}
- cd->marc8_esc_mode = *inp++;
inbytesleft--;
+ ch = *inp++;
+ if (inbytesleft > 0 && (ch == '(' || ch == ','))
+ {
+ inbytesleft--;
+ cd->g0_mode = *inp++;
+ }
+ else if (inbytesleft > 0 && (ch == ')' || ch == '-'))
+ {
+ inbytesleft--;
+ cd->g1_mode = *inp++;
+ }
+ else
+ cd->g0_mode = ch;
+
(*no_read) += inbytesleft0 - inbytesleft;
}
if (inbytesleft <= 0)
{
unsigned long x;
size_t no_read_sub = 0;
+ int mode = *inp < 128 ? cd->g0_mode : cd->g1_mode;
*comb = 0;
- switch(cd->marc8_esc_mode)
+ switch(mode)
{
case 'B': /* Basic ASCII */
case 's': /* ASCII */
if (cd->init_flag)
{
cd->my_errno = YAZ_ICONV_UNKNOWN;
- cd->marc8_esc_mode = 'B';
+ cd->g0_mode = 'B';
+ cd->g1_mode = 'B';
cd->comb_offset = cd->comb_size = 0;
cd->compose_char = 0;
* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: tsticonv.c,v 1.33 2007-11-16 08:01:47 adam Exp $
+ * $Id: tsticonv.c,v 1.34 2008-03-05 21:21:22 adam Exp $
*/
#if HAVE_CONFIG_H
#include <yaz/yaz-util.h>
#include <yaz/test.h>
+#define ESC "\x1b"
+
static int compare_buffers(char *msg, int no,
int expect_len, const char *expect_buf,
int got_len, const char *got_buf)
if (!cd)
return;
+ /* bug #2115 */
+ YAZ_CHECK(tst_convert(cd, ESC "(N" ESC ")Qp" ESC "(B", "\xd0\x9f"));
+
+
YAZ_CHECK(tst_convert(cd, "Cours de math",
"Cours de math"));
/* COMBINING ACUTE ACCENT */
YAZ_CHECK(tst_convert(cd, "Cours de mathâe",
"Cours de mathe\xcc\x81"));
-
YAZ_CHECK(tst_convert(cd, "a\xea\x1e", "a\x1e\xcc\x8a"));
YAZ_CHECK(tst_convert(cd, "a\xea", "a"));
+
yaz_iconv_close(cd);
}