X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fwrbuf.c;h=d8a709e0ed304da0ce93238d0a6a24e00d43cbd8;hb=afae1117609712743c1109597d080a53a8dac5d4;hp=ef2be4ceb8727930b9ab1d4f22942061e381b8e8;hpb=401da56d4a26f687cd42024bdef6f29a29bb7663;p=yaz-moved-to-github.git diff --git a/src/wrbuf.c b/src/wrbuf.c index ef2be4c..d8a709e 100644 --- a/src/wrbuf.c +++ b/src/wrbuf.c @@ -2,7 +2,7 @@ * Copyright (C) 1995-2007, Index Data ApS * See the file LICENSE for details. * - * $Id: wrbuf.c,v 1.18 2007-03-19 14:40:07 adam Exp $ + * $Id: wrbuf.c,v 1.20 2007-09-17 19:14:26 adam Exp $ */ /** @@ -213,6 +213,19 @@ 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); } +void wrbuf_iconv_reset(WRBUF b, yaz_iconv_t cd) +{ + if (cd) + { + char outbuf[12]; + size_t outbytesleft = sizeof(outbuf); + char *outp = outbuf; + size_t r = yaz_iconv(cd, 0, 0, &outp, &outbytesleft); + if (r != (size_t) (-1)) + wrbuf_write(b, outbuf, outp - outbuf); + } +} + const char *wrbuf_cstr(WRBUF b) { wrbuf_putc(b, '\0'); /* add '\0' */ @@ -227,6 +240,16 @@ void wrbuf_cut_right(WRBUF b, size_t no_to_remove) b->pos = b->pos - no_to_remove; } +void wrbuf_verbose_str(WRBUF b, const char *str, size_t len) +{ + size_t i; + for (i = 0; i < len; i++) + if (str[i] < ' ' || str[i] > 126) + wrbuf_printf(b, "\\x%02X", str[i] & 0xff); + else + wrbuf_putc(b, str[i]); +} + /* * Local variables: * c-basic-offset: 4