Fixed bug #643: Bad sequence for MARC conversions from UTF-8 to MARC-8.
[yaz-moved-to-github.git] / src / wrbuf.c
index 47dbe9a..fe3065b 100644 (file)
@@ -2,7 +2,7 @@
  * Copyright (C) 1995-2005, Index Data ApS
  * See the file LICENSE for details.
  *
- * $Id: wrbuf.c,v 1.10 2006-04-19 10:05:03 adam Exp $
+ * $Id: wrbuf.c,v 1.12 2006-08-28 12:34:41 adam Exp $
  */
 
 /**
@@ -81,6 +81,21 @@ int wrbuf_puts(WRBUF b, const char *buf)
     return 0;
 }
 
+int wrbuf_puts_replace_char(WRBUF b, const char *buf, 
+                            const char from, const char to)
+{
+    while(*buf){
+        if (*buf == from)
+            wrbuf_putc(b, to);
+        else
+            wrbuf_putc(b, *buf);
+        buf++;
+    }
+    wrbuf_putc(b, 0);
+    (b->pos)--;                          /* don't include '\0' in count */
+    return 0;
+}
+
 void wrbuf_chop_right(WRBUF b)
 {
     while (b->pos && b->buf[b->pos-1] == ' ')
@@ -200,6 +215,13 @@ int wrbuf_iconv_puts(WRBUF b, yaz_iconv_t cd, const char *strz)
     return wrbuf_iconv_write(b, cd, strz, strlen(strz));
 }
 
+int wrbuf_iconv_putchar(WRBUF b, yaz_iconv_t cd, int ch)
+{
+    char buf[1];
+    buf[0] = ch;
+    return wrbuf_iconv_write(b, cd, buf, 1);
+}
+
 int wrbuf_iconv_write_cdata(WRBUF b, yaz_iconv_t cd, const char *buf, int size)
 {
     return wrbuf_iconv_write_x(b, cd, buf, size, 1);