21 size_t inbytesleft, outbytesleft;
22 char *outbufp1, *outbufp2, *instrp;
25 size_t len=vecsize(instr);
29 outbufp1= outbufp2= malloc(outbytesleft);
35 cd=iconv_open(argv[1]->c.str.chars, argv[0]->
c.
str.
chars);
38 ret=iconv(cd, &instrp, &inbytesleft, &outbufp2, &outbytesleft);
40 else outstr=
makestring(outbufp1, len*2-outbytesleft);
53 cd=iconv_open(argv[0]->c.str.chars, argv[1]->
c.
str.
chars);
54 return(mkbigint(cd));}
59 cd=bigintval(argv[0]);
65 {
int cd, ret, malloced=
NULL;
66 char *srcstrp, *deststrp, *deststrpv, deststr[1024];
67 size_t srcstrlen, deststrlen;
71 cd=bigintval(argv[0]);
74 srcstrlen=strlength(argv[1]);
75 deststrlen=2*srcstrlen;
76 if (deststrlen>=1024) {
77 deststrp=malloc(deststrlen);
79 else deststrp=deststr;
81 ret=iconv(cd, &srcstrp, &srcstrlen, &deststrpv, &deststrlen);
82 if (ret== -1) { dest=
NIL;
goto iconvend;}
83 dest=
makestring(deststrp, 2*strlength(argv[1])-deststrlen);
85 if (malloced) cfree(deststrp);
pointer ICONV(context *ctx, int n, pointer *argv)
pointer ICONVOPEN(context *ctx, int n, pointer *argv)
defun("ADR_TO_STRING", mod, ADR_TO_STRING)
charconv(context *ctx, int n, pointer argv[])
pointer ICONVCLOSE(context *ctx, int n, pointer *argv)
static pointer cconv(context *ctx, int n, pointer *argv)
pointer error(enum errorcode ec,...) pointer error(va_alist) va_dcl
pointer makestring(char *, int)