c->code <<= 4;
c->remains = 2;
}
+ c->code &= 0xffff;
c->state = UTF8_WRITE_CONT;
/* fall-thru */
case UTF8_WRITE_CONT:
return CONV_SOURCE_END;
send_utf:
- c->state = UTF8_WRITE_START;
if (cc < 0xe0) { c->code = cc & 0x1f; c->remains = 1; }
else if (cc < 0xf0) { c->code = cc & 0x0f; c->remains = 2; }
else
else if (cc < 0xfe) c->remains = 5;
else goto nocode;
}
+ c->state = UTF8_READ;
goto go_slow;
dend_str:
c->state = SEQ_WRITE;
c->string_at = k;
c->remains = len;
+ goto go_slow;
dend_char:
c->state = SINGLE_WRITE;
c->code = code;
- goto go_slow;
go_slow:
c->source = s;
c->dest = d;
return CONV_DEST_END;
dend_utf:
- c->source = s;
+ c->source = s+1;
c->dest = d;
c->state = UTF8_WRITE_START;
c->code = code;
{
return sizeof(x_to_uni) / sizeof(x_to_uni[0]);
}
+
+int
+conv_in_to_ucs(struct conv_context *c, unsigned int y)
+{
+ return x_to_uni[c->in_to_x[y]];
+}
+
+int conv_ucs_to_out(struct conv_context *c, unsigned int ucs)
+{
+ uns x = uni_to_x[ucs >> 8U][ucs & 0xff];
+ if (x == 256 || c->x_to_out[x] >= 256)
+ return -1;
+ else
+ return c->x_to_out[x];
+}