Emoji support
This commit is contained in:
parent
4f76bb0590
commit
fce665ee3d
1 changed files with 31 additions and 3 deletions
|
|
@ -65,12 +65,28 @@ static const char utf8_bytes[256] = {
|
||||||
0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
|
||||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||||
|
|
||||||
|
static int code = 0;
|
||||||
|
|
||||||
static int
|
static int
|
||||||
readchar() {
|
readchar() {
|
||||||
#ifdef UTF8
|
#ifdef UTF8
|
||||||
int c[4];
|
int c[4];
|
||||||
int i = 0, j;
|
int i = 0, j;
|
||||||
int n = 0;
|
int n = 0, cod;
|
||||||
|
|
||||||
|
if(code == -1) {
|
||||||
|
code = 0;
|
||||||
|
|
||||||
|
return ']';
|
||||||
|
} else if(code != 0) {
|
||||||
|
int h = code & 0xf;
|
||||||
|
char* hex = "0123456789ABCDEF";
|
||||||
|
code = code >> 4;
|
||||||
|
|
||||||
|
if(code == 0) code = -1;
|
||||||
|
|
||||||
|
return hex[h];
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if((c[i++] = getch()) == EOF) return EOF;
|
if((c[i++] = getch()) == EOF) return EOF;
|
||||||
|
|
@ -79,7 +95,13 @@ readchar() {
|
||||||
if(i == 1) {
|
if(i == 1) {
|
||||||
n = c[0];
|
n = c[0];
|
||||||
} else {
|
} else {
|
||||||
n |= c[0] & (0xff >> (8 - i - 1));
|
int f = 0xff;
|
||||||
|
|
||||||
|
if(i == 2) f = f >> 3;
|
||||||
|
if(i == 3) f = f >> 4;
|
||||||
|
if(i == 4) f = f >> 5;
|
||||||
|
|
||||||
|
n |= c[0] & f;
|
||||||
|
|
||||||
for(j = 1; j < i; j++) {
|
for(j = 1; j < i; j++) {
|
||||||
n = n << 6;
|
n = n << 6;
|
||||||
|
|
@ -87,7 +109,13 @@ readchar() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return unicode_to_eucjp(n);
|
if((cod = unicode_to_eucjp(n)) == -1) {
|
||||||
|
code = n;
|
||||||
|
|
||||||
|
return '[';
|
||||||
|
}
|
||||||
|
|
||||||
|
return cod;
|
||||||
#else
|
#else
|
||||||
int c1;
|
int c1;
|
||||||
int c2;
|
int c2;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue