X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fwrbuf.c;h=f90764ace03ad0f7dc8eeba707efa458f917f9b7;hb=be821514c869d68186361b5aab6bbfd1aa60e087;hp=ef2be4ceb8727930b9ab1d4f22942061e381b8e8;hpb=401da56d4a26f687cd42024bdef6f29a29bb7663;p=yaz-moved-to-github.git diff --git a/src/wrbuf.c b/src/wrbuf.c index ef2be4c..f90764a 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.19 2007-03-20 21:37:32 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' */