Mercurial > pidgin.yaz
comparison src/protocols/oscar/oscar.c @ 10097:158950e7996d
[gaim-migrate @ 11119]
I wrote this code with the assumption that iconv would fail if Gaim
attempted to convert utf8 to an encoding that could not represent
all the characters.
This assumption is not true for all version of iconv
(NetBSD 2.0, in this case).
Pope not Calle of Flaxborough (notcalle) pointed this out and
provided a fix.
Thanks!
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Thu, 14 Oct 2004 03:44:42 +0000 |
parents | 2923a6c59192 |
children | fb4216714dac |
comparison
equal
deleted
inserted
replaced
10096:2923a6c59192 | 10097:158950e7996d |
---|---|
496 GError *err = NULL; | 496 GError *err = NULL; |
497 aim_userinfo_t *userinfo = NULL; | 497 aim_userinfo_t *userinfo = NULL; |
498 const gchar *charsetstr; | 498 const gchar *charsetstr; |
499 gsize msglen; | 499 gsize msglen; |
500 | 500 |
501 *charset = oscar_charset_check(from); | |
502 | |
501 /* Attempt to send as ASCII */ | 503 /* Attempt to send as ASCII */ |
502 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); | 504 if (*charset == AIM_CHARSET_ASCII) { |
503 if (*msg != NULL) { | 505 *msg = g_convert(from, strlen(from), "ASCII", "UTF-8", NULL, &msglen, NULL); |
504 *charset = AIM_CHARSET_ASCII; | |
505 *charsubset = 0x0000; | 506 *charsubset = 0x0000; |
506 *msglen_int = msglen; | 507 *msglen_int = msglen; |
507 return; | 508 return; |
508 } | 509 } |
509 | 510 |
530 */ | 531 */ |
531 charsetstr = "ISO-8859-1"; | 532 charsetstr = "ISO-8859-1"; |
532 if ((destsn != NULL) && aim_sn_is_icq(destsn)) | 533 if ((destsn != NULL) && aim_sn_is_icq(destsn)) |
533 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); | 534 charsetstr = gaim_account_get_string(account, "encoding", OSCAR_DEFAULT_CUSTOM_ENCODING); |
534 | 535 |
536 /* | |
537 * XXX - We need a way to only attempt to convert if we KNOW "from" | |
538 * can be converted to "charsetstr" | |
539 */ | |
535 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); | 540 *msg = g_convert(from, strlen(from), charsetstr, "UTF-8", NULL, &msglen, NULL); |
536 if (*msg != NULL) { | 541 if (*msg != NULL) { |
537 *charset = AIM_CHARSET_CUSTOM; | 542 *charset = AIM_CHARSET_CUSTOM; |
538 *charsubset = 0x0000; | 543 *charsubset = 0x0000; |
539 *msglen_int = msglen; | 544 *msglen_int = msglen; |
5497 | 5502 |
5498 if (!text) { | 5503 if (!text) { |
5499 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); | 5504 aim_locate_setprofile(od->sess, NULL, "", 0, NULL, NULL, 0); |
5500 return; | 5505 return; |
5501 } | 5506 } |
5502 | 5507 |
5503 text_html = gaim_strdup_withhtml(text); | 5508 text_html = gaim_strdup_withhtml(text); |
5504 charset = oscar_charset_check(text_html); | 5509 charset = oscar_charset_check(text_html); |
5505 if (charset == AIM_CHARSET_UNICODE) { | 5510 if (charset == AIM_CHARSET_UNICODE) { |
5506 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); | 5511 msg = g_convert(text_html, strlen(text_html), "UCS-2BE", "UTF-8", NULL, &msglen, NULL); |
5507 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); | 5512 aim_locate_setprofile(od->sess, "unicode-2-0", msg, (msglen > od->rights.maxsiglen ? od->rights.maxsiglen : msglen), NULL, NULL, 0); |
5614 "has been exceeded. Gaim has truncated it for you.", | 5619 "has been exceeded. Gaim has truncated it for you.", |
5615 od->rights.maxawaymsglen), od->rights.maxawaymsglen); | 5620 od->rights.maxawaymsglen), od->rights.maxawaymsglen); |
5616 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); | 5621 gaim_notify_warning(gc, NULL, _("Away message too long."), errstr); |
5617 g_free(errstr); | 5622 g_free(errstr); |
5618 } | 5623 } |
5619 | 5624 |
5620 g_free(text_html); | 5625 g_free(text_html); |
5621 | 5626 |
5622 return; | 5627 return; |
5623 } | 5628 } |
5624 | 5629 |