+ case SHIFT_JIS:
+ if (c < 128) goto revout;
+ if (c == 0xa5) {
+ x++;
+ c = '\\';
+ goto revout;
+ }
+ if (c == 0x203e) {
+ x++;
+ c = '~';
+ goto revout;
+ }
+ if (c-0xff61 <= 0xdf-0xa1) {
+ c += 0xa1 - 0xff61;
+ goto revout;
+ }
+ c = uni_to_jis(c);
+ if (!c) goto subst;
+ if (*outb < 2) goto toobig;
+ d = c%256;
+ c = c/256;
+ *(*out)++ = (c+1)/2 + (c<95 ? 112 : 176);
+ *(*out)++ = c%2 ? d + 31 + d/96 : d + 126;
+ *outb -= 2;
+ break;
+ case EUC_JP:
+ if (c < 128) goto revout;
+ if (c-0xff61 <= 0xdf-0xa1) {
+ c += 0x0e00 + 0x21 - 0xff61;
+ } else {
+ c = uni_to_jis(c);
+ }
+ if (!c) goto subst;
+ if (*outb < 2) goto toobig;
+ *(*out)++ = c/256 + 0x80;
+ *(*out)++ = c%256 + 0x80;
+ *outb -= 2;
+ break;
+ case ISO2022_JP:
+ if (c < 128) goto revout;
+ if (c-0xff61 <= 0xdf-0xa1 || c==0xa5 || c==0x203e) {
+ if (*outb < 7) goto toobig;
+ *(*out)++ = '\033';
+ *(*out)++ = '(';
+ if (c==0xa5) {
+ *(*out)++ = 'J';
+ *(*out)++ = '\\';
+ } else if (c==0x203e) {
+ *(*out)++ = 'J';
+ *(*out)++ = '~';
+ } else {
+ *(*out)++ = 'I';
+ *(*out)++ = c-0xff61+0x21;
+ }
+ *(*out)++ = '\033';
+ *(*out)++ = '(';
+ *(*out)++ = 'B';
+ *outb -= 7;
+ break;
+ }
+ c = uni_to_jis(c);
+ if (!c) goto subst;
+ if (*outb < 8) goto toobig;
+ *(*out)++ = '\033';
+ *(*out)++ = '$';
+ *(*out)++ = 'B';
+ *(*out)++ = c/256;
+ *(*out)++ = c%256;
+ *(*out)++ = '\033';
+ *(*out)++ = '(';
+ *(*out)++ = 'B';
+ *outb -= 8;
+ break;
+ case UCS2:
+ totype = UCS2BE;