Mercurial > pidgin
comparison src/util.c @ 1985:008a4cc4a82c
[gaim-migrate @ 1995]
hi.
committer: Tailor Script <tailor@pidgin.im>
| author | Eric Warmenhoven <eric@warmenhoven.org> |
|---|---|
| date | Mon, 11 Jun 2001 09:21:18 +0000 |
| parents | 24aed1c31342 |
| children | 9a2e3902658c |
comparison
equal
deleted
inserted
replaced
| 1984:e90a0164436c | 1985:008a4cc4a82c |
|---|---|
| 1522 } | 1522 } |
| 1523 | 1523 |
| 1524 fclose(fd); | 1524 fclose(fd); |
| 1525 } | 1525 } |
| 1526 | 1526 |
| 1527 unsigned char *utf8_to_str(unsigned char *in) | |
| 1528 { | |
| 1529 int n = 0,i = 0; | |
| 1530 int inlen; | |
| 1531 unsigned char *result; | |
| 1532 | |
| 1533 if (!in) | |
| 1534 return NULL; | |
| 1535 | |
| 1536 inlen = strlen(in); | |
| 1537 | |
| 1538 result = g_malloc(inlen+1); | |
| 1539 | |
| 1540 while(n <= inlen-1) { | |
| 1541 long c = (long)in[n]; | |
| 1542 if(c<0x80) | |
| 1543 result[i++] = (char)c; | |
| 1544 else { | |
| 1545 if((c&0xC0) == 0xC0) | |
| 1546 result[i++] = (char)(((c&0x03)<<6)|(((unsigned char)in[++n])&0x3F)); | |
| 1547 else if((c&0xE0) == 0xE0) { | |
| 1548 if (n + 2 <= inlen) { | |
| 1549 result[i] = (char)(((c&0xF)<<4)|(((unsigned char)in[++n])&0x3F)); | |
| 1550 result[i] = (char)(((unsigned char)result[i]) |(((unsigned char)in[++n])&0x3F)); | |
| 1551 i++; | |
| 1552 } else n += 2; | |
| 1553 } | |
| 1554 else if((c&0xF0) == 0xF0) | |
| 1555 n += 3; | |
| 1556 else if((c&0xF8) == 0xF8) | |
| 1557 n += 4; | |
| 1558 else if((c&0xFC) == 0xFC) | |
| 1559 n += 5; | |
| 1560 } | |
| 1561 n++; | |
| 1562 } | |
| 1563 result[i] = '\0'; | |
| 1564 | |
| 1565 return result; | |
| 1566 } | |
| 1567 | |
| 1527 time_t get_time(int year, int month, int day, int hour, int min, int sec) | 1568 time_t get_time(int year, int month, int day, int hour, int min, int sec) |
| 1528 { | 1569 { |
| 1529 struct tm tm; | 1570 struct tm tm; |
| 1530 | 1571 |
| 1531 tm.tm_year = year - 1900; | 1572 tm.tm_year = year - 1900; |
