#endif
}
+/*#define ICUTF8/**/
+/*
+ 1\95¶\8e\9a\82Ì\92·\82³\82ð\95Ô\82·
+ */
+static int
+charlen(unsigned int c)
+{
+#ifdef ICUTF8
+ if(c >= 0xf0){
+ return 4;
+ }
+ if(c >= 0xc0){
+ return 3;
+ }
+#endif
+ if(c >= 0x80){
+ return 2;
+ }
+ return 1;
+}
+
/*
* 2\83o\83C\83g\95¶\8e\9a\82ð\83o\83b\83t\83@\83\8a\83\93\83O\82µ\82È\82ª\82ç\8fo\97Í\82·\82é
* \8a¿\8e\9a\83R\81[\83h\95Ï\8a·\82à\8ds\82¤
*/
+#ifdef ICUTF8
+int
+jbuffer(
+ unsigned int c,
+ unsigned int *buf,
+ void (*f1)(unsigned int),
+ void (*f2)(unsigned char *))
+{
+ static unsigned char ibuf[8];
+ static int bufcnt = 0;
+ static int buflen;
+ int cnt;
+
+ if(!buf) buf = ibuf;
+ if(!f1) f1 = tty_jputc;
+ if(!f2) f2 = tty_jputc2;
+
+ c = c & 0xff;
+
+ if(bufcnt == 0){
+ cnt = charlen(c);
+ if(cnt == 1){
+ f1(c);
+ return 1;
+ }
+ buflen = cnt;
+ ibuf[bufcnt++] = c;
+ return 0;
+ }
+
+ ibuf[bufcnt++] = c;
+ if(bufcnt < buflen){
+ return 0;
+ }
+
+ ibuf[bufcnt] = '\0';
+ f2(ibuf);
+ bufcnt = 0;
+}
+#else
int
jbuffer(
unsigned int c,
}
return -1;
}
+#endif
/*
* 2\83o\83C\83g\95¶\8e\9a\82ð\83o\83b\83t\83@\83\8a\83\93\83O\82µ\82È\82ª\82ç\8fo\97Í\82·\82é