- /* Resulting string can be longer after the conversion.
- * The following constant must be at least 3 for conversion to UTF-8
- * and at least the maximum length of the strings in string_table for other charsets. */
- return 3 * l + 1;
+uns
+stk_strconv_step(struct conv_context *c, byte *buf, uns len)
+{
+ if (!c->source_end)
+ {
+ memcpy(buf, c->source, len);
+ c->dest_start = buf;
+ return 0;
+ }
+ if (c->dest_start)
+ {
+ uns l = c->dest_end - c->dest_start;
+ memcpy(buf, c->dest_start, l);
+ c->dest = buf + l;
+ }
+ else
+ c->dest = buf;
+ c->dest_start = buf;
+ c->dest_end = buf + len;
+ if (conv_run(c) & CONV_SOURCE_END)
+ return 0;
+ return len << 1;