Mercurial > pidgin
comparison src/util.c @ 2039:859e9c2c5813
[gaim-migrate @ 2049]
utf8
committer: Tailor Script <tailor@pidgin.im>
author | Eric Warmenhoven <eric@warmenhoven.org> |
---|---|
date | Sat, 16 Jun 2001 19:16:25 +0000 |
parents | 9a2e3902658c |
children | d5033540df18 |
comparison
equal
deleted
inserted
replaced
2038:cb4fbcdae9eb | 2039:859e9c2c5813 |
---|---|
1558 n += 4; | 1558 n += 4; |
1559 else if((c&0xFC) == 0xFC) | 1559 else if((c&0xFC) == 0xFC) |
1560 n += 5; | 1560 n += 5; |
1561 } | 1561 } |
1562 n++; | 1562 n++; |
1563 } | 1563 } |
1564 result[i] = '\0'; | 1564 result[i] = '\0'; |
1565 | 1565 |
1566 return result; | 1566 return result; |
1567 } | |
1568 | |
1569 char *str_to_utf8(unsigned char *in) | |
1570 { | |
1571 int n = 0,i = 0; | |
1572 int inlen; | |
1573 char *result = NULL; | |
1574 | |
1575 if (!in) | |
1576 return NULL; | |
1577 | |
1578 inlen = strlen(in); | |
1579 | |
1580 result = g_malloc(inlen * 2 + 1); | |
1581 | |
1582 while (n < inlen) { | |
1583 long c = (long)in[n]; | |
1584 if (c == 27) { | |
1585 n += 2; | |
1586 if (in[n] == 'x') | |
1587 n++; | |
1588 if (in[n] == '3') | |
1589 n++; | |
1590 n += 2; | |
1591 continue; | |
1592 } | |
1593 if ((c == 0x0D) || (c == 0x0A)) { | |
1594 n++; continue; | |
1595 } | |
1596 if (c < 128) | |
1597 result[i++] = (char)c; | |
1598 else { | |
1599 result[i++] = (char)((c>>6)|192); | |
1600 result[i++] = (char)((c&63)|128); | |
1601 } | |
1602 n++; | |
1603 } | |
1604 result[i] = '\0'; | |
1605 | |
1606 return result; | |
1567 } | 1607 } |
1568 | 1608 |
1569 time_t get_time(int year, int month, int day, int hour, int min, int sec) | 1609 time_t get_time(int year, int month, int day, int hour, int min, int sec) |
1570 { | 1610 { |
1571 struct tm tm; | 1611 struct tm tm; |