Mercurial > pidgin
comparison src/oscar.c @ 2064:1f51e772a05c
[gaim-migrate @ 2074]
Convert UNICODE messages to plain ASCII, using HTML UNICODE entities where necessary.
committer: Tailor Script <tailor@pidgin.im>
author | Adam Fritzler <mid@auk.cx> |
---|---|
date | Thu, 28 Jun 2001 19:53:48 +0000 |
parents | 94e4580095e0 |
children | 05df89293018 |
comparison
equal
deleted
inserted
replaced
2063:f27177a54007 | 2064:1f51e772a05c |
---|---|
1695 ir->request = TRUE; | 1695 ir->request = TRUE; |
1696 ir->timestamp = args->iconstamp; | 1696 ir->timestamp = args->iconstamp; |
1697 } | 1697 } |
1698 #endif | 1698 #endif |
1699 | 1699 |
1700 g_snprintf(tmp, BUF_LONG, "%s", args->msg); | 1700 /* |
1701 * Quickly convert it to eight bit format, replacing | |
1702 * non-ASCII UNICODE characters with their equivelent | |
1703 * HTML entity. | |
1704 */ | |
1705 if (args->icbmflags & AIM_IMFLAGS_UNICODE) { | |
1706 int i; | |
1707 | |
1708 for (i = 0, tmp[0] = '\0'; i < args->msglen; i += 2) { | |
1709 unsigned short uni; | |
1710 | |
1711 uni = ((args->msg[i] & 0xff) << 8) | (args->msg[i+1] & 0xff); | |
1712 | |
1713 if ((uni < 128) || ((uni >= 160) && (uni <= 255))) { /* ISO 8859-1 */ | |
1714 | |
1715 g_snprintf(tmp+strlen(tmp), sizeof(tmp)-strlen(tmp), "%c", uni); | |
1716 | |
1717 } else { /* something else, do UNICODE entity */ | |
1718 g_snprintf(tmp+strlen(tmp), sizeof(tmp)-strlen(tmp), "&#%04x;", uni); | |
1719 } | |
1720 } | |
1721 } else | |
1722 g_snprintf(tmp, BUF_LONG, "%s", args->msg); | |
1723 | |
1701 serv_got_im(gc, userinfo->sn, tmp, args->icbmflags & AIM_IMFLAGS_AWAY, time(NULL)); | 1724 serv_got_im(gc, userinfo->sn, tmp, args->icbmflags & AIM_IMFLAGS_AWAY, time(NULL)); |
1702 g_free(tmp); | 1725 g_free(tmp); |
1703 } else if (channel == 2) { | 1726 } else if (channel == 2) { |
1704 struct aim_incomingim_ch2_args *args; | 1727 struct aim_incomingim_ch2_args *args; |
1705 args = va_arg(ap, struct aim_incomingim_ch2_args *); | 1728 args = va_arg(ap, struct aim_incomingim_ch2_args *); |