Index: gtk/plugins/relnot.c
===================================================================
--- gtk/plugins/relnot.c	(revision 18168)
+++ gtk/plugins/relnot.c	(working copy)
@@ -35,7 +35,7 @@
 #include "core.h"
 #include "notify.h"
 #include "prefs.h"
-#include "util.h"
+#include "libgaim/util.h"
 #include "version.h"
 
 /* 1 day */
Index: gtk/gtkconv.c
===================================================================
--- gtk/gtkconv.c	(revision 18168)
+++ gtk/gtkconv.c	(working copy)
@@ -130,6 +130,10 @@
 static GdkColor *nick_colors = NULL;
 static guint nbr_nick_colors;
 
+/* yaz. If you want to use shortcut keys that may conflict with
+   inputmethods, change this to 1. */
+#define ENABLE_SHORTCUT 0
+
 typedef struct {
 	GtkWidget *window;
 
@@ -2711,20 +2715,34 @@
 
 	{ "/Conversation/sep0", NULL, NULL, 0, "<Separator>", NULL },
 
+#if ENABLE_SHORTCUT
 	{ N_("/Conversation/_Find..."), NULL, menu_find_cb, 0,
 			"<StockItem>", GTK_STOCK_FIND },
+#else
+	{ N_("/Conversation/_Find..."), NULL, menu_find_cb, 0,
+			"<Item>" },
+#endif
 	{ N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", GAIM_STOCK_LOG },
 	{ N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0,
 			"<StockItem>", GTK_STOCK_SAVE_AS },
+
+#if ENABLE_SHORTCUT
 	{ N_("/Conversation/Clea_r Scrollback"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR },
-
+#else
+	{ N_("/Conversation/Clea_r Scrollback"), NULL, menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR },
+#endif
 	{ "/Conversation/sep1", NULL, NULL, 0, "<Separator>", NULL },
 
 	{ N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER },
 	{ N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb,
 			0, "<StockItem>", GAIM_STOCK_POUNCE },
+#if ENABLE_SHORTCUT
 	{ N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0,
 			"<StockItem>", GAIM_STOCK_INFO },
+#else
+	{ N_("/Conversation/_Get Info"), NULL, menu_get_info_cb, 0,
+			"<StockItem>", GAIM_STOCK_INFO },
+#endif
 	{ N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0,
 			"<StockItem>", GAIM_STOCK_INVITE },
 	{ N_("/Conversation/M_ore"), NULL, NULL, 0, "<Branch>", NULL },
@@ -3257,7 +3275,12 @@
 		gtk_widget_destroy(win->menu.send_to);
 
 	/* Build the Send To menu */
+
+#if ENABLE_SHORTCUT
 	win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To"));
+#else
+	win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("Send To"));
+#endif
 	gtk_widget_show(win->menu.send_to);
 
 	menu = gtk_menu_new();
@@ -3730,7 +3753,9 @@
 	GaimConversation *conv = gtkconv->active_conv;
 	GaimGtkChatPane *gtkchat;
 	char *new_topic;
-	const char *current_topic;
+//	const char *current_topic;
+	char dummy[] = "No Topic";
+	char *current_topic = NULL;
 
 	gc      = gaim_conversation_get_gc(conv);
 
@@ -3743,7 +3768,12 @@
 	gtkconv = GAIM_GTK_CONVERSATION(conv);
 	gtkchat = gtkconv->u.chat;
 	new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text)));
+//	gaim_debug_info("yaz gtkconv", "new_topic=%s\n", new_topic);
+	
 	current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv));
+	if(!current_topic)
+		current_topic = dummy;
+//	gaim_debug_info("yaz gtkconv", "current_topic=%s\n", current_topic);
 
 	if(current_topic && !g_utf8_collate(new_topic, current_topic)){
 		g_free(new_topic);
Index: gtk/gtkimhtml.c
===================================================================
--- gtk/gtkimhtml.c	(revision 18168)
+++ gtk/gtkimhtml.c	(working copy)
@@ -95,6 +95,10 @@
                            gint              y,
                            guint             time);
 
+/* yaz. If you want to use shortcut keys that may conflict with
+   inputmethods, change this to 1. */
+#define ENABLE_SHORTCUT 0
+
 static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml);
 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml);
 static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextIter *end, GtkIMHtml *imhtml);
@@ -403,10 +407,11 @@
 static gint
 gtk_imhtml_tip (gpointer data)
 {
-	GtkIMHtml *imhtml = data;
+	GtkIMHtml *imhtml = (GtkIMHtml *)data;
 	PangoFontMetrics *font_metrics;
 	PangoLayout *layout;
 	PangoFont *font;
+	PangoLanguage *lang;
 
 	gint gap, x, y, h, w, scr_w, baseline_skip;
 
@@ -447,7 +452,9 @@
 		return FALSE;
 	}
 
-	font_metrics = pango_font_get_metrics(font, NULL);
+	lang = pango_context_get_language (pango_layout_get_context(layout));
+	font_metrics = pango_font_get_metrics(font, lang); //it's ok.
+//	font_metrics = pango_font_get_metrics(font, NULL); //crash!
 
 	pango_layout_get_pixel_size(layout, &scr_w, NULL);
 	gap = PANGO_PIXELS((pango_font_metrics_get_ascent(font_metrics) +
@@ -552,14 +559,15 @@
 			g_source_remove(GTK_IMHTML(imhtml)->tip_timer);
 		GTK_IMHTML(imhtml)->tip_timer = 0;
 	}
-
+//yaz here bomb explodes
+#if 1
 	if (tip){
 		if (!GTK_IMHTML(imhtml)->editable)
 			gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->hand_cursor);
 		GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT,
 							       gtk_imhtml_tip, imhtml);
 	}
-
+#endif
 	GTK_IMHTML(imhtml)->tip = tip;
 	g_slist_free(tags);
 	return FALSE;
Index: gtk/gtkprefs.c
===================================================================
--- gtk/gtkprefs.c	(revision 18168)
+++ gtk/gtkprefs.c	(working copy)
@@ -917,7 +917,7 @@
 #endif
 
 	gaim_gtk_prefs_checkbox(_("Use smooth-scrolling"), "/gaim/gtk/conversations/use_smooth_scrolling", vbox);
-
+	gaim_gtk_prefs_checkbox(_("Use msn messenger style"), "/core/conversations/msnstyle", vbox);//yaz
 #ifdef _WIN32
 	gaim_gtk_prefs_checkbox(_("F_lash window when IMs are received"), "/gaim/gtk/win32/blink_im", vbox);
 #endif
Index: gtk/gtkimhtmltoolbar.h
===================================================================
--- gtk/gtkimhtmltoolbar.h	(revision 18168)
+++ gtk/gtkimhtmltoolbar.h	(working copy)
@@ -30,7 +30,7 @@
 extern "C" {
 #endif
 
-#define DEFAULT_FONT_FACE "Helvetica 12"
+#define DEFAULT_FONT_FACE "Sans 12"
 
 #define GTK_TYPE_IMHTMLTOOLBAR            (gtk_imhtmltoolbar_get_type ())
 #define GTK_IMHTMLTOOLBAR(obj)            (GTK_CHECK_CAST ((obj), GTK_TYPE_IMHTMLTOOLBAR, GtkIMHtmlToolbar))
Index: gtk/gtkmain.c
===================================================================
--- gtk/gtkmain.c	(revision 18168)
+++ gtk/gtkmain.c	(working copy)
@@ -202,10 +202,12 @@
 		gaim_debug_warning("sighandler", "Caught signal %d\n", sig);
 		gaim_connections_disconnect_all();
 		break;
+#if 1
 	case SIGSEGV:
 		fprintf(stderr, "%s", segfault_message);
 		abort();
 		break;
+#endif
 	case SIGCHLD:
 		/* Restore signal catching */
 		signal(SIGCHLD, sighandler);
Index: console/libgnt/gnttextview.c
===================================================================
--- console/libgnt/gnttextview.c	(revision 18168)
+++ console/libgnt/gnttextview.c	(working copy)
@@ -56,7 +56,13 @@
 			char back = *end;
 			*end = '\0';
 			wattrset(widget->window, seg->flags);
-			wprintw(widget->window, "%s", (view->string->str + seg->start));
+//			wprintw(widget->window, "%s", (view->string->str + seg->start));
+			{
+				char *tmp = NULL;
+				tmp = g_locale_from_utf8(view->string->str + seg->start, -1, NULL, NULL, NULL);
+				wprintw(widget->window, "%s", tmp);
+				g_free(tmp);
+			}
 			*end = back;
 		}
 		wattroff(widget->window, A_UNDERLINE | A_BLINK | A_REVERSE);
Index: libgaim/util.c
===================================================================
--- libgaim/util.c	(revision 18168)
+++ libgaim/util.c	(working copy)
@@ -1091,6 +1091,8 @@
 		return FALSE;
 
 	q = strstr(p, end_token);
+	if(q == NULL) //yaz
+		return FALSE;
 
 	/* Trim leading blanks */
 	while (*p != '\n' && g_ascii_isspace(*p)) {
@@ -1103,7 +1105,7 @@
 	}
 
 	/* Don't bother with null strings */
-	if (p == q)
+	if (p >= q)
 		return FALSE;
 
 	if (q != NULL && (!no_value_token ||
@@ -4035,3 +4037,233 @@
 	return buf;
 }
 
+
+void botch_ucs(gchar *ucs, gssize len)
+{
+	gint i;
+
+ 	for(i=0;i<len;i+=2){
+ 		switch(*(ucs+i)){
+ 		case 0x00:
+ 			switch(*(ucs+i+1)){
+ 			case 0xa2:	// ¢
+ 				*(ucs+i) = 0xff;
+ 				*(ucs+i+1) = 0xe0;
+ 				break;
+ 			case 0xa3:	// £
+ 				*(ucs+i) = 0xff;
+				*(ucs+i+1) = 0xe1;
+ 				break;
+ 			case 0xac:	// ¬
+ 				*(ucs+i) = 0xff;
+ 				*(ucs+i+1) = 0xe2;
+ 				break;
+ 			}
+ 			break;
+ 		case 0x20:	// ‖
+ 			if(*(ucs+i+1) == 0x16){
+ 				*(ucs+i) = 0x22;
+				*(ucs+i+1) = 0x25;
+ 			}
+ 			break;
+ 		case 0x22:	// −
+ 			if(*(ucs+i+1) == 0x12){
+ 				*(ucs+i) = 0xff;
+ 				*(ucs+i+1) = 0x0d;
+ 			}
+ 			break;
+ 		case 0x30:	// 〜
+ 			if(*(ucs+i+1) == 0x1c){
+ 				*(ucs+i) = 0xff;
+ 				*(ucs+i+1) = 0x5e;
+ 			}
+ 			break;
+ 		}
+ 	}
+
+}
+
+void sanitize_ucs(gchar *ucs, gssize len)
+{
+	gint i;
+
+	for(i=0;i<len;i+=2){
+		switch(*(ucs+i)){
+		case 0x22:
+			switch(*(ucs+i+1)){
+			case 0x25:	// ‖
+				*(ucs+i) = 0x20;
+				*(ucs+i+1) = 0x16;
+				break;
+			}
+			break;
+		case 0xff:
+			switch(*(ucs+i+1)){
+			case 0x0d:	// −
+				*(ucs+i) = 0x22;
+				*(ucs+i+1) = 0x12;
+				break;
+			case 0x5e:	// 〜
+				*(ucs+i) = 0x30;
+				*(ucs+i+1) = 0x1c;
+				break;
+			case 0xe0:	// ¢
+				*(ucs+i) = 0x00;
+				*(ucs+i+1) = 0xa2;
+				break;
+			case 0xe1:	// £
+				*(ucs+i) = 0x00;
+				*(ucs+i+1) = 0xa3;
+				break;
+			case 0xe2:	// ¬
+				*(ucs+i) = 0x00;
+				*(ucs+i+1) = 0xac;
+				break;
+			}
+			break;
+		}
+	}
+}
+
+guchar *sanitize_utf(unsigned char *msg, size_t len, size_t *newlen)
+{
+	gint i;
+	size_t bytes;
+	unsigned char *utf;
+
+	utf = g_strndup(msg, len);
+
+	bytes = len;
+
+	for(i=0;i<len;i++){
+		switch(*(utf+i)){
+		case 0xe2:
+			if(*(utf+i+1) == 0x88) {
+				if(*(utf+i+2) == 0xa5) {	// ‖
+					*(utf+i) = 0xe2;
+					*(utf+i+1) = 0x80;
+					*(utf+i+2) = 0x96;
+				}
+			}
+			break;
+		case 0xef:
+			switch(*(utf+i+1)){
+			case 0xbc:
+				if(*(utf+i+2) == 0x8d) {	// −
+					*(utf+i) = 0xe2;
+					*(utf+i+1) = 0x88;
+					*(utf+i+2) = 0x92;
+				}
+				break;
+			case 0xbd:
+				if(*(utf+i+2) == 0x9e) {	// 〜
+					*(utf+i) = 0xe3;
+					*(utf+i+1) = 0x80;
+					*(utf+i+2) = 0x9c;
+				}
+				break;
+			case 0xbf:
+				switch(*(utf+i+2)){
+			       case 0xa0:// ¢
+				       *(utf+i) = 0xc2;
+				       *(utf+i+1) = 0xa2;
+				       memmove(utf+i+2, utf+i+3,
+					       len-i-3); //1byte詰める
+				       bytes--;
+				       break;
+			       case 0xa1:	// £
+				       *(utf+i) = 0xc2;
+				       *(utf+i+1) = 0xa3;
+				       memmove(utf+i+2, utf+i+3,
+					       len-i-3); //1byte詰める
+				       bytes--;
+				       break;
+			       case 0xa2:	// ¬
+				       *(utf+i) = 0xc2;
+				       *(utf+i+1) = 0xac;
+				       memmove(utf+i+2, utf+i+3,
+					       len-i-3); //1byte詰める
+				       bytes--;
+				       break;
+			       }
+			       break;
+			}
+			break;
+		}
+	}
+	*(utf+bytes)= 0x00; //terminate
+	*newlen = bytes;
+	return utf;
+}
+
+
+guchar *botch_utf(const void *msg, size_t len, size_t *newlen)
+{
+ 	int i,bytes;
+	unsigned char *utf;
+
+	bytes = len;
+
+	utf = g_malloc0(bytes*3/2+1); /* new length might be 3/2 in the worst case */
+	memcpy(utf, msg, bytes);
+	
+ 	for(i=0;i<bytes;i++){
+ 		switch(*(utf+i)){
+ 		case 0xc2:
+ 			switch(*(utf+i+1)){
+ 			case 0xa2:	// ¢
+ 				*(utf+i) = 0xef;
+ 				*(utf+i+1) = 0xbf;
+				memmove(utf+i+3, utf+i+2, bytes-i-2);
+				*(utf+i+2) = 0xa0;
+				bytes++;
+ 				break;
+ 			case 0xa3:	// £
+ 				*(utf+i) = 0xef;
+ 				*(utf+i+1) = 0xbf;
+				memmove(utf+i+3, utf+i+2, bytes-i-2);
+				*(utf+i+2) = 0xa1;
+				bytes++;
+ 				break;
+ 			case 0xac:	// ¬
+ 				*(utf+i) = 0xef;
+ 				*(utf+i+1) = 0xbf;
+				memmove(utf+i+3, utf+i+2, bytes-i-2);
+				*(utf+i+2) = 0xa2;
+				bytes++;
+ 				break;
+ 			}
+ 			break;
+ 		case 0xe2:
+			switch(*(utf+i+1)){
+			case 0x80:	// ‖
+				if(*(utf+i+2) == 0x96){
+					*(utf+i) = 0xe2;
+					*(utf+i+1) = 0x88;
+					*(utf+i+2) = 0xa5;
+				}
+				break;
+			case 0x88:	// −
+				if(*(utf+i+1) == 0x92){
+					*(utf+i) = 0xef;
+					*(utf+i+1) = 0xbc;
+					*(utf+i+2) = 0x8d;
+				}
+				break;
+			}
+			break;
+ 		case 0xe3:	// 〜
+ 			if(*(utf+i+1) == 0x80){
+				if(*(utf+i+2) == 0x9c){
+					*(utf+i) = 0xef;
+					*(utf+i+1) = 0xbd;
+					*(utf+i+2) = 0x9e;
+				}
+ 			}
+ 			break;
+ 		} //switch
+ 	}
+	*(utf+bytes) = 0x00; //terminate
+	*newlen = bytes;
+	return utf;
+}
Index: libgaim/util.h
===================================================================
--- libgaim/util.h	(revision 18168)
+++ libgaim/util.h	(working copy)
@@ -1068,4 +1068,9 @@
 }
 #endif
 
+/* to address incompatibility with cp932. */
+void botch_ucs(gchar *ucs, gssize len);
+void sanitize_ucs(gchar *ucs, gssize len);
+guchar *botch_utf(const void *utf, size_t len, size_t *newlen);
+guchar *sanitize_utf(unsigned char *msg, size_t len, size_t *newlen);
 #endif /* _GAIM_UTIL_H_ */
Index: libgaim/conversation.c
===================================================================
--- libgaim/conversation.c	(revision 18168)
+++ libgaim/conversation.c	(working copy)
@@ -1093,17 +1093,27 @@
 			  GaimMessageFlags flags, time_t mtime)
 {
 	GaimConversation *c;
+	char *tmpmessage = NULL;
 
 	g_return_if_fail(im != NULL);
 	g_return_if_fail(message != NULL);
 
 	c = gaim_conv_im_get_conversation(im);
 
+	// yaz
+	if (gaim_prefs_get_bool("/core/conversations/msnstyle")) {
+		tmpmessage = g_strdup_printf("<br>%s", message);
+	} else {
+		tmpmessage = g_strdup_printf("%s", message);
+	}
+
 	/* Raise the window, if specified in prefs. */
 	if (c->ui_ops != NULL && c->ui_ops->write_im != NULL)
-		c->ui_ops->write_im(c, who, message, flags, mtime);
+		c->ui_ops->write_im(c, who, tmpmessage, flags, mtime);
 	else
-		gaim_conversation_write(c, who, message, flags, mtime);
+		gaim_conversation_write(c, who, tmpmessage, flags, mtime);
+
+	g_free(tmpmessage);
 }
 
 gboolean gaim_conv_present_error(const char *who, GaimAccount *account, const char *what)
Index: libgaim/protocols/yahoo/yahoo_profile.c
===================================================================
--- libgaim/protocols/yahoo/yahoo_profile.c	(revision 18168)
+++ libgaim/protocols/yahoo/yahoo_profile.c	(working copy)
@@ -22,6 +22,7 @@
  */
 
 #define PHOTO_SUPPORT 1
+// yaz original is 1
 
 #include "internal.h"
 #include "debug.h"
@@ -737,6 +738,8 @@
 
 #endif /* PHOTO_SUPPORT */
 
+
+#define PROF_LEN (1024 * 10)
 static void yahoo_got_info(GaimUtilFetchUrlData *url_data, gpointer user_data,
 		const gchar *url_text, size_t len, const gchar *error_message)
 {
@@ -998,7 +1001,7 @@
 				strings->charset, NULL, NULL, NULL);
 		yahoo_remove_nonbreaking_spaces(last_updated_utf8_string);
 
-		gaim_debug_misc("yahoo", "after utf8 conversion: stripped = (%s)\n", stripped);
+		gaim_debug_misc("yahoo", "after utf8 conversion: stripped = (%s)\n", stripped); //yaz: payload
 	}
 
 	if (profile_state == PROFILE_STATE_DEFAULT) {
@@ -1034,17 +1037,20 @@
 	/* extract their Email address and put it in */
 	found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info,
 			strings->my_email_string, 1, " ", 0,
-			strings->private_string, _("E-Mail"), 0, NULL, NULL);
+//			strings->private_string, _("E-Mail"), 0, NULL, NULL);
+			strings->private_string, "メール", 0, NULL, NULL);
 
 	/* extract the Nickname if it exists */
 	found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info,
 			"Nickname:", 1, "\n", '\n',
-			NULL, _("Nickname"), 0, NULL, NULL);
+//			NULL, _("Nickname"), 0, NULL, NULL);
+			NULL, "ニックネーム", 0, NULL, NULL);
 
 	/* extract their RealName and put it in */
 	found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info,
 			strings->realname_string, 1, "\n", '\n',
-			NULL, _("Real Name"), 0, NULL, NULL);
+//			NULL, _("Real Name"), 0, NULL, NULL);
+			NULL, "名前", 0, NULL, NULL);
 
 	/* extract their Location and put it in */
 	found |= gaim_markup_extract_info_field(stripped, stripped_len, user_info,
@@ -1219,9 +1225,21 @@
 	g_free(stripped);
 
 	/* show it to the user */
+#if 0
+	if(g_utf8_validate(s->str, -1, NULL)){
+		gaim_notify_userinfo(info_data->gc, info_data->name,
+				     s->str, NULL, NULL);
+	}
+	else
+	{
+		gaim_notify_userinfo(info_data->gc, info_data->name,
+				     "Parsing user profile failed.\n", NULL, NULL);
+	}
+#else
 	gaim_notify_userinfo(info_data->gc, info_data->name,
 						  user_info, NULL, NULL);
 	gaim_notify_user_info_destroy(user_info);
+#endif
 
 	g_free(last_updated_utf8_string);
 	g_free(url_buffer);
Index: libgaim/protocols/yahoo/util.c
===================================================================
--- libgaim/protocols/yahoo/util.c	(revision 18168)
+++ libgaim/protocols/yahoo/util.c	(working copy)
@@ -29,6 +29,7 @@
 #include "prpl.h"
 
 #include "yahoo.h"
+#include "util.h"
 
 #include <string.h>
 
@@ -47,7 +48,8 @@
 char *yahoo_string_encode(GaimConnection *gc, const char *str, gboolean *utf8)
 {
 	struct yahoo_data *yd = gc->proto_data;
-	char *ret;
+	char *ret, *strtmp;
+	int newlen;
 	const char *to_codeset;
 
 	if (yd->jp && utf8 && *utf8)
@@ -61,7 +63,12 @@
 	else
 		to_codeset = gaim_account_get_string(gaim_connection_get_account(gc), "local_charset",  "ISO-8859-1");
 
-	ret = g_convert_with_fallback(str, strlen(str), to_codeset, "UTF-8", "?", NULL, NULL, NULL);
+	strtmp = sanitize_utf((char *)str, strlen((char *)str), &newlen);
+
+	ret = g_convert_with_fallback(strtmp, strlen(strtmp), to_codeset, "UTF-8", "?", NULL, NULL, NULL);
+
+	g_free(strtmp);
+
 	if (ret)
 		return ret;
 	else
@@ -79,8 +86,9 @@
 char *yahoo_string_decode(GaimConnection *gc, const char *str, gboolean utf8)
 {
 	struct yahoo_data *yd = gc->proto_data;
-	char *ret;
-	const char *from_codeset;
+	char *ret, *tmp;
+	char *from_codeset;
+	int newlen;
 
 	if (utf8) {
 		if (g_utf8_validate(str, -1, NULL))
@@ -92,10 +100,21 @@
 	else
 		from_codeset = gaim_account_get_string(gaim_connection_get_account(gc), "local_charset",  "ISO-8859-1");
 
-	ret = g_convert_with_fallback(str, strlen(str), "UTF-8", from_codeset, NULL, NULL, NULL, NULL);
+	/* yaz: it's a kind of voodoo to avoid malconversion of "~". */
+	tmp = g_convert(str, strlen(str), "EUC-JP", from_codeset, NULL, NULL, NULL);
+	if(tmp) { 
+		ret = g_convert(tmp, strlen(tmp), "UTF-8", "EUC-JP", NULL, NULL, NULL);
+		g_free(tmp);
+	} else {
+		ret = g_convert_with_fallback(str, strlen(str), "UTF-8", from_codeset, NULL, NULL, NULL, NULL);
+	}
 
-	if (ret)
+	if (ret){
+		tmp = ret;
+		ret = botch_utf(ret, strlen(ret), &newlen);
+		g_free(tmp);
 		return ret;
+	}
 	else
 		return g_strdup("");
 }
Index: libgaim/protocols/yahoo/yahoo.c
===================================================================
--- libgaim/protocols/yahoo/yahoo.c	(revision 18168)
+++ libgaim/protocols/yahoo/yahoo.c	(working copy)
@@ -3946,7 +3946,7 @@
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
 
 
-#if 0
+#if 1
 	option = gaim_account_option_string_new(_("Chat room list URL"), "room_list", YAHOO_ROOMLIST_URL);
 	prpl_info.protocol_options = g_list_append(prpl_info.protocol_options, option);
 
Index: libgaim/protocols/jabber/message.c
===================================================================
--- libgaim/protocols/jabber/message.c	(revision 18168)
+++ libgaim/protocols/jabber/message.c	(working copy)
@@ -285,13 +285,22 @@
 				jm->thread_id = xmlnode_get_data(child);
 		} else if(!strcmp(child->name, "body")) {
 			if(!jm->body) {
-				char *msg = xmlnode_to_str(child, NULL);
+				char *tmp, *msg;
+				int len;
+				tmp = xmlnode_to_str(child, NULL);
+				msg = sanitize_utf(tmp, strlen(tmp), &len);
 				jm->body = gaim_strdup_withhtml(msg);
-				g_free(msg);
+				g_free(msg); g_free(tmp);
 			}
 		} else if(!strcmp(child->name, "html")) {
-			if(!jm->xhtml && xmlnode_get_child(child, "body"))
-				jm->xhtml = xmlnode_to_str(child, NULL);
+			if(!jm->xhtml && xmlnode_get_child(child, "body")){
+				char *tmp, *msg;
+				int len;
+				tmp = xmlnode_to_str(child, NULL);
+				msg = sanitize_utf(tmp, strlen(tmp), &len);
+				jm->xhtml = msg;
+				g_free(tmp);
+			}
 		} else if(!strcmp(child->name, "active")) {
 			jm->chat_state = JM_STATE_ACTIVE;
 			jm->typing_style |= JM_TS_JEP_0085;
Index: libgaim/protocols/jabber/jabber.c
===================================================================
--- libgaim/protocols/jabber/jabber.c	(revision 18168)
+++ libgaim/protocols/jabber/jabber.c	(working copy)
@@ -342,8 +342,8 @@
 
 void jabber_send(JabberStream *js, xmlnode *packet)
 {
-	char *txt;
-	int len;
+	char *txt, *utf;
+	int len, utflen;
 
 	gaim_signal_emit(my_protocol, "jabber-sending-xmlnode", js->gc, &packet);
 
@@ -352,8 +352,9 @@
 		return;
 
 	txt = xmlnode_to_str(packet, &len);
-	jabber_send_raw(js, txt, len);
-	g_free(txt);
+	utf = botch_utf(txt, len, &utflen); //yaz
+	jabber_send_raw(js, utf, utflen);
+	g_free(txt); g_free(utf);
 }
 
 static void jabber_keepalive(GaimConnection *gc)
Index: libgaim/protocols/msn/switchboard.c
===================================================================
--- libgaim/protocols/msn/switchboard.c	(revision 18168)
+++ libgaim/protocols/msn/switchboard.c	(working copy)
@@ -885,13 +885,18 @@
 	}
 	else
 	{
-		serv_got_im(gc, passport, body_final, 0, time(NULL));
+		char *yaz_body_final;
+//		yaz_body_final = g_strdup_printf("<br>%s", body_final);
+		yaz_body_final = gaim_strreplace(body_final, "\r\n", "<br>"); // replace 0D 0A with <br>
+		gaim_debug_info("yaz msn", "yaz_body_final=%s\n", yaz_body_final);
+		serv_got_im(gc, passport, yaz_body_final, 0, time(NULL));
 		if (swboard->conv == NULL)
 		{
 			swboard->conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM,
 									passport, gaim_connection_get_account(gc));
 			swboard->flag |= MSN_SB_FLAG_IM;
 		}
+		g_free(yaz_body_final);
 	}
 
 	g_free(body_final);
Index: libgaim/protocols/msn/msg.c
===================================================================
--- libgaim/protocols/msn/msg.c	(revision 18168)
+++ libgaim/protocols/msn/msg.c	(working copy)
@@ -525,9 +525,7 @@
 
 	if (data != NULL && len > 0)
 	{
-		msg->body = g_malloc0(len + 1);
-		memcpy(msg->body, data, len);
-		msg->body_len = len;
+		msg->body = botch_utf((void *)data, len, &msg->body_len); /* yaz */
 	}
 	else
 	{
Index: libgaim/protocols/msn/msn.c
===================================================================
--- libgaim/protocols/msn/msn.c	(revision 18168)
+++ libgaim/protocols/msn/msn.c	(working copy)
@@ -140,6 +140,8 @@
 	msn_cmdproc_send(cmdproc, "REA", "%s %s",
 					 gaim_account_get_username(account),
 					 alias);
+	//yaz
+	gaim_account_set_alias(account, entry); //oct16
 }
 
 static void
@@ -250,6 +252,12 @@
 }
 
 static void
+msn_set_friendly_name(GaimConnection *gc, const char *name, const char *alias)
+{
+	msn_act_id(gc, alias);
+}
+
+static void
 msn_show_set_home_phone(GaimPluginAction *action)
 {
 	GaimConnection *gc;
@@ -1994,7 +2002,7 @@
 	NULL,					/* register_user */
 	NULL,					/* get_cb_info */
 	NULL,					/* get_cb_away */
-	NULL,					/* alias_buddy */
+	msn_set_friendly_name,			/* alias_buddy */
 	msn_group_buddy,		/* group_buddy */
 	msn_rename_group,		/* rename_group */
 	NULL,					/* buddy_free */
Index: libgaim/protocols/oscar/family_icbm.c
===================================================================
--- libgaim/protocols/oscar/family_icbm.c	(revision 18168)
+++ libgaim/protocols/oscar/family_icbm.c	(working copy)
@@ -51,6 +51,10 @@
 #include "win32dep.h"
 #endif
 
+/* yaz */
+#include "debug.h"
+#include "../../util.h"
+
 /**
  * Add a standard ICBM header to the given bstream with the given
  * information.
@@ -453,6 +457,9 @@
 	guchar cookie[8];
 	aim_tlvlist_t *otl = NULL, *itl = NULL;
 	ByteStream hdrbs;
+	// yaz
+	char *ucs = NULL;
+	int bytes;
 
 	if (!od || !(conn = flap_connection_findbygroup(od, 0x0004)))
 		return -EINVAL;
@@ -492,15 +499,51 @@
 	 * raw data, followed by a series of TLVs.
 	 *
 	 */
+#if 0
 	byte_stream_new(&hdrbs, 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2);
 
 	byte_stream_put16(&hdrbs, 0x0000); /* Unknown! */
 	byte_stream_putraw(&hdrbs, cookie, sizeof(cookie)); /* I think... */
 	byte_stream_putcaps(&hdrbs, OSCAR_CAPABILITY_CHAT);
+#endif
+	//yaz
+	// convert msg to ascii first. if it succeed, send as plain ascii.
+	// if it fails, convert msg into ucs-2be, and send it. 
+	ucs = g_convert(msg, strlen(msg), "ASCII", "UTF-8", NULL, &bytes, NULL);
+	if(ucs){
+		byte_stream_new(&hdrbs, 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2);
 
+		byte_stream_put16(&hdrbs, 0x0000); /* Unknown! */
+		byte_stream_putraw(&hdrbs, cookie, sizeof(cookie)); /* I think... */
+		byte_stream_putcaps(&hdrbs, OSCAR_CAPABILITY_CHAT);
+
+		aim_tlvlist_add_16(&itl, 0x000a, 0x0001);
+		aim_tlvlist_add_noval(&itl, 0x000f);
+		aim_tlvlist_add_raw(&itl, 0x000c, strlen(msg), msg);
+		free(ucs);
+	} else {
+		byte_stream_new(&hdrbs, 2+8+16+6+4+4+strlen(msg)+4+2+1+strlen(roomname)+2+4+11);
+
+		byte_stream_put16(&hdrbs, 0x0000); /* Unknown! */
+		byte_stream_putraw(&hdrbs, cookie, sizeof(cookie)); /* I think... */
+		byte_stream_putcaps(&hdrbs, OSCAR_CAPABILITY_CHAT);
+
+		aim_tlvlist_add_16(&itl, 0x000a, 0x0001);
+		aim_tlvlist_add_raw(&itl, 0x000d, 11, "unicode-2-0");
+		aim_tlvlist_add_noval(&itl, 0x000f);
+		//yaz
+		ucs = g_convert(msg, strlen(msg), "UCS-2BE", "UTF-8", NULL, &bytes, NULL);
+		if(ucs){
+			botch_ucs(ucs, bytes);
+			aim_tlvlist_add_raw(&itl, 0x000c, bytes, ucs);
+			free(ucs);
+		}
+	}
+#if 0
 	aim_tlvlist_add_16(&itl, 0x000a, 0x0001);
 	aim_tlvlist_add_noval(&itl, 0x000f);
 	aim_tlvlist_add_str(&itl, 0x000c, msg);
+#endif
 	aim_tlvlist_add_chatroom(&itl, 0x2711, exchange, roomname, instance);
 	aim_tlvlist_write(&hdrbs, &itl);
 
Index: libgaim/protocols/oscar/oscar.c
===================================================================
--- libgaim/protocols/oscar/oscar.c	(revision 18168)
+++ libgaim/protocols/oscar/oscar.c	(working copy)
@@ -278,7 +278,8 @@
 
 	/* Make sure encoding begins with charset= */
 	if (strncmp(encoding, "text/aolrtf; charset=", 21) &&
-		strncmp(encoding, "text/x-aolrtf; charset=", 23))
+	    strncmp(encoding, "text/x-aolrtf; charset=", 23) &&
+	    strncmp(encoding, "text/plain; charset=", 20)) /* for iChat */
 	{
 		return NULL;
 	}
@@ -300,7 +301,25 @@
 	gchar *utf8 = NULL;
 
 	if ((encoding == NULL) || encoding[0] == '\0') {
-		gaim_debug_info("oscar", "Empty encoding, assuming UTF-8\n");
+		gaim_debug_info("yaz oscar", "Empty encoding, validate as UTF-8\n");
+		if(g_utf8_validate(text, textlen, NULL)){
+			size_t newlen;
+			utf8 = sanitize_utf(text, textlen, &newlen);
+			goto done;
+		}
+		// not UTF-8
+		gaim_debug_info("yaz oscar", "Empty encoding, assuming UCS-2BE\n");
+		sanitize_ucs(text, textlen);
+		utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL);
+		if(utf8){
+			if(!g_utf8_validate(utf8, strlen(utf8), NULL)){
+				gaim_debug_info("yaz oscar", "Invalid conversion\n");
+				g_free(utf8);
+				utf8 = NULL;
+			}
+		} else {
+			gaim_debug_info("yaz oscar", "Conversion failed\n");
+		}
 	} else if (!strcasecmp(encoding, "iso-8859-1")) {
 		utf8 = g_convert(text, textlen, "UTF-8", "iso-8859-1", NULL, NULL, NULL);
 	} else if (!strcasecmp(encoding, "ISO-8859-1-Windows-3.1-Latin-1") ||
@@ -308,6 +327,7 @@
 	{
 		utf8 = g_convert(text, textlen, "UTF-8", "Windows-1252", NULL, NULL, NULL);
 	} else if (!strcasecmp(encoding, "unicode-2-0")) {
+		sanitize_ucs(text, textlen);
 		utf8 = g_convert(text, textlen, "UTF-8", "UCS-2BE", NULL, NULL, NULL);
 	} else if (strcasecmp(encoding, "utf-8")) {
 		gaim_debug_warning("oscar", "Unrecognized character encoding \"%s\", "
@@ -328,7 +348,7 @@
 		else
 			utf8 = g_strndup(text, textlen);
 	}
-
+done:
 	return utf8;
 }
 
@@ -485,6 +505,7 @@
 		if ((b != NULL) && (GAIM_BUDDY_IS_ONLINE(b)))
 		{
 			*msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, NULL);
+			botch_ucs(*msg, msglen);
 			if (*msg != NULL)
 			{
 				*charset = AIM_CHARSET_UNICODE;
@@ -519,6 +540,7 @@
 	 * Nothing else worked, so send as UCS-2BE.
 	 */
 	*msg = g_convert(from, strlen(from), "UCS-2BE", "UTF-8", NULL, &msglen, &err);
+	botch_ucs(*msg, msglen);
 	if (*msg != NULL) {
 		*charset = AIM_CHARSET_UNICODE;
 		*charsubset = 0x0000;
@@ -1963,6 +1985,8 @@
 		tmp = gaim_plugin_oscar_decode_im_part(account, userinfo->sn, curpart->charset,
 				curpart->charsubset, curpart->data, curpart->datalen);
 		if (tmp != NULL) {
+			gaim_str_strip_char(tmp, 0x0d); // yaz: strip CR
+//			gaim_debug_info("yaz oscar", "tmp=%s",tmp);
 			g_string_append(message, tmp);
 			g_free(tmp);
 		}
@@ -2063,6 +2087,7 @@
 		char *encoding, *utf8name, *tmp;
 		GHashTable *components;
 
+//		gaim_debug_info("yaz oscar", "chat request %s\n", args->msg);
 		if (!args->info.chat.roominfo.name || !args->info.chat.roominfo.exchange) {
 			g_free(message);
 			return 1;
@@ -2085,6 +2110,8 @@
 		g_hash_table_replace(components, g_strdup("room"), utf8name);
 		g_hash_table_replace(components, g_strdup("exchange"),
 				g_strdup_printf("%d", args->info.chat.roominfo.exchange));
+		gaim_debug_info("yaz oscar", "about to call serv_got_chat_invite\n");
+//		gaim_debug_info("yaz oscar", "name=%s message=%s\n", name ? name : args->info.chat.roominfo.name, message);
 		serv_got_chat_invite(gc,
 				     utf8name,
 				     userinfo->sn,
@@ -2316,7 +2343,7 @@
 	 * for this suck-ass part of the protocol by splitting the string into at
 	 * most 1 baby string.
 	 */
-	msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0));
+	msg1 = g_strsplit(args->msg, "\376", (args->type == 0x01 ? 1 : 0)); // \376 is 0xfe
 	for (numtoks=0; msg1[numtoks]; numtoks++);
 	msg2 = (gchar **)g_malloc((numtoks+1)*sizeof(gchar *));
 	for (i=0; msg1[i]; i++) {
@@ -4141,7 +4168,7 @@
 	/* Append any binary data that we may have */
 	if (oscar_id) {
 		msg = g_string_append_len(msg, data->str, data->len);
-		msg = g_string_append(msg, "</BINARY>");
+		msg = g_string_append(msg, "</BINARY>"); // yaz: mistake!
 	}
 	g_string_free(data, TRUE);
 
@@ -4344,6 +4371,7 @@
 	charset = oscar_charset_check(str);
 	if (charset == AIM_CHARSET_UNICODE) {
 		encoded = g_convert(str, strlen(str), "UCS-2BE", "UTF-8", NULL, ret_len, NULL);
+		botch_ucs(encoded, *ret_len);
 		*encoding = "unicode-2-0";
 	} else if (charset == AIM_CHARSET_CUSTOM) {
 		encoded = g_convert(str, strlen(str), "ISO-8859-1", "UTF-8", NULL, ret_len, NULL);
@@ -5361,7 +5389,7 @@
 		charsetstr = "unicode-2-0";
 	else if (charset == AIM_CHARSET_CUSTOM)
 		charsetstr = "iso-8859-1";
-	aim_chat_send_im(od, c->conn, 0, buf2, len, charsetstr, "en");
+	aim_chat_send_im(od, c->conn, 0, buf2, len, charsetstr, "JA");
 	g_free(buf2);
 
 	return 0;
Index: libgaim/notify.c
===================================================================
--- libgaim/notify.c	(revision 18168)
+++ libgaim/notify.c	(working copy)
@@ -449,6 +449,9 @@
 		gaim_signal_emit(gaim_notify_get_handle(), "displaying-userinfo",
 						 gaim_connection_get_account(gc), who, user_info);
 
+		g_return_val_if_fail(g_utf8_validate(who, -1, NULL), NULL); //yaz
+		g_return_val_if_fail(g_utf8_validate(user_info, -1, NULL), NULL); //yaz
+
 		info->ui_handle = ops->notify_userinfo(gc, who, user_info);
 		info->cb = cb;
 		info->cb_user_data = user_data;
