pidgin: 1aa8a701: Change OSCAR to use UTF-16 rather than U...

elb at pidgin.im elb at pidgin.im
Thu Mar 6 23:05:49 EST 2008


-----------------------------------------------------------------
Revision: 1aa8a701c81527c4f91549a4546a54262fccce6d
Ancestor: 258d2052d62513fdcb210736e51ad27be49f17a6
Author: elb at pidgin.im
Date: 2008-03-07T04:01:20
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/1aa8a701c81527c4f91549a4546a54262fccce6d

Modified files:
        ChangeLog libpurple/protocols/oscar/family_locate.c
        libpurple/protocols/oscar/oscar.c
        libpurple/protocols/oscar/oscar.h

ChangeLog: 

Change OSCAR to use UTF-16 rather than UCS-2 conversions.  Apparently
some iconv implementations (notably win_iconv) are dropping UCS-2
support, due to the impression that it is obsolete.  For BMP
characters, UTF-16 should be bitwise identical to UCS-2, so if OSCAR
really *is* UCS-2, this shouldn't hurt anything.  If it turns out it's
capable of UTF-16, well, then, more's the better.

-------------- next part --------------
============================================================
--- ChangeLog	4b6d115c79c7a06cc9aeaca273965abe680f9a4e
+++ ChangeLog	bb2de653a44e9913d5639508664e476658184d0d
@@ -1,5 +1,11 @@ Pidgin and Finch: The Pimpin' Penguin IM
 Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
 
+version 2.4.1 ():
+	libpurple
+	* Treat AIM Unicode messages as UTF-16 rather than UCS-2; this
+	  should have no functional effect, other than continued support
+	  on systems which have dropped UCS-2 conversions.
+
 version 2.4.0 (02/29/2008):
 	libpurple:
 	* Added support for offline messages for AIM accounts (thanks to
============================================================
--- libpurple/protocols/oscar/family_locate.c	d9fd12a4efeacb5c0c56d54850dd5c970f9e105f
+++ libpurple/protocols/oscar/family_locate.c	f77b3d8efd4bbb315d9c42ace1a815b04163eb3a
@@ -1031,7 +1031,7 @@ rights(OscarData *od, FlapConnection *co
  * restricted to a few choices.  I am currently aware of:
  *
  * us-ascii		Just that
- * unicode-2-0		UCS2-BE
+ * unicode-2-0		UTF-16BE
  *
  * profile_len and awaymsg_len MUST be set similarly, and they MUST
  * be the length of their respective strings in bytes.
============================================================
--- libpurple/protocols/oscar/oscar.c	1a0a82103413801c9589d383afad014b6710d789
+++ libpurple/protocols/oscar/oscar.c	49ab59d0e34a8459f99e958a723d119620a55f6c
@@ -245,7 +245,7 @@ oscar_charset_check(const char *utf8)
 	}
 
 	/*
-	 * Must we send this message as UNICODE (in the UCS-2BE encoding)?
+	 * Must we send this message as UNICODE (in the UTF-16BE encoding)?
 	 */
 	while (utf8[i])
 	{
@@ -314,14 +314,14 @@ oscar_encoding_to_utf8(PurpleAccount *ac
 	} else if (!g_ascii_strcasecmp(encoding, "unicode-2-0")) {
 		/* Some official ICQ clients are apparently total crack,
 		 * and have been known to save a UTF-8 string converted
-		 * from the locale character set to UCS-2 (not from UTF-8
-		 * to UCS-2!) in the away message.  This hack should find
+		 * from the locale character set to UTF-16 (not from UTF-8
+		 * to UTF-16!) in the away message.  This hack should find
 		 * and do something (un)reasonable with that, and not
 		 * mess up too much else. */
 		const gchar *charset = purple_account_get_string(account, "encoding", NULL);
 		if (charset) {
 			gsize len;
-			utf8 = g_convert(text, textlen, charset, "UCS-2BE", &len, NULL, NULL);
+			utf8 = g_convert(text, textlen, charset, "UTF-16BE", &len, NULL, NULL);
 			if (!utf8 || len != textlen || !g_utf8_validate(utf8, -1, NULL)) {
 				g_free(utf8);
 				utf8 = NULL;
@@ -330,7 +330,7 @@ oscar_encoding_to_utf8(PurpleAccount *ac
 			}
 		}
 		if (!utf8)
-			utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL);
+			utf8 = g_convert(text, textlen, "UTF-8", "UTF-16BE", NULL, NULL, NULL);
 	} else if (g_ascii_strcasecmp(encoding, "utf-8")) {
 		purple_debug_warning("oscar", "Unrecognized character encoding \"%s\", "
 						   "attempting to convert to UTF-8 anyway\n", encoding);
@@ -423,7 +423,7 @@ purple_plugin_oscar_decode_im_part(Purpl
 		return NULL;
 
 	if (charset == AIM_CHARSET_UNICODE) {
-		charsetstr1 = "UCS-2BE";
+		charsetstr1 = "UTF-16BE";
 		charsetstr2 = "UTF-8";
 	} else if (charset == AIM_CHARSET_CUSTOM) {
 		if ((sourcesn != NULL) && aim_snvalid_icq(sourcesn))
@@ -495,7 +495,7 @@ purple_plugin_oscar_convert_to_best_enco
 	 * If we're sending to an ICQ user, and they are in our
 	 * buddy list, and they are advertising the Unicode
 	 * capability, and they are online, then attempt to send
-	 * as UCS-2BE.
+	 * as UTF-16BE.
 	 */
 	if ((destsn != NULL) && aim_snvalid_icq(destsn))
 		userinfo = aim_locate_finduserinfo(od, destsn);
@@ -506,7 +506,7 @@ purple_plugin_oscar_convert_to_best_enco
 		b = purple_find_buddy(account, destsn);
 		if ((b != NULL) && (PURPLE_BUDDY_IS_ONLINE(b)))
 		{
-			*msg = g_convert(from, -1, "UCS-2BE", "UTF-8", NULL, &msglen, NULL);
+			*msg = g_convert(from, -1, "UTF-16BE", "UTF-8", NULL, &msglen, NULL);
 			if (*msg != NULL)
 			{
 				*charset = AIM_CHARSET_UNICODE;
@@ -538,9 +538,9 @@ purple_plugin_oscar_convert_to_best_enco
 	}
 
 	/*
-	 * Nothing else worked, so send as UCS-2BE.
+	 * Nothing else worked, so send as UTF-16BE.
 	 */
-	*msg = g_convert(from, -1, "UCS-2BE", "UTF-8", NULL, &msglen, &err);
+	*msg = g_convert(from, -1, "UTF-16BE", "UTF-8", NULL, &msglen, &err);
 	if (*msg != NULL) {
 		*charset = AIM_CHARSET_UNICODE;
 		*charsubset = 0x0000;
@@ -4436,7 +4436,7 @@ gchar *purple_prpl_oscar_convert_to_info
 
 	charset = oscar_charset_check(str);
 	if (charset == AIM_CHARSET_UNICODE) {
-		encoded = g_convert(str, -1, "UCS-2BE", "UTF-8", NULL, ret_len, NULL);
+		encoded = g_convert(str, -1, "UTF-16BE", "UTF-8", NULL, ret_len, NULL);
 		*encoding = "unicode-2-0";
 	} else if (charset == AIM_CHARSET_CUSTOM) {
 		encoded = g_convert(str, -1, "ISO-8859-1", "UTF-8", NULL, ret_len, NULL);
============================================================
--- libpurple/protocols/oscar/oscar.h	c717758ac587d55c4f78d02e0940fb3c3b1f2740
+++ libpurple/protocols/oscar/oscar.h	e0168c2cb1f5b530919af14fa62e8786c0df4bde
@@ -754,7 +754,7 @@ void oscar_chat_destroy(struct chat_conn
 #define AIM_IMFLAGS_TYPINGNOT			0x1000 /* typing notification */
 
 #define AIM_CHARSET_ASCII		0x0000
-#define AIM_CHARSET_UNICODE	0x0002 /* UCS-2BE */
+#define AIM_CHARSET_UNICODE	0x0002 /* UTF-16BE */
 #define AIM_CHARSET_CUSTOM	0x0003
 
 /*


More information about the Commits mailing list