--- src/sendmsg.c.orig	Tue Nov  9 00:18:40 1999
+++ src/sendmsg.c	Mon Nov 29 17:24:48 1999
@@ -20,13 +20,15 @@
 #define SOCKS 1
 #include <socks.h>
 #endif
+#include <jlib.h>
 
 int search_wait;
 
 DWORD our_session;
 
 /*** Local function declarations ***/
-static char *cr_convert( const gchar *text );
+static gchar *cr_convert( const gchar *text );
+static gchar *cr_unconvert( const gchar *text );
 static void Wrinkle( void *buf, size_t len );
 static void Gen_Checksum( BYTE * buf, DWORD len );
 static DWORD Scramble_cc( DWORD cc );
@@ -211,7 +213,7 @@
  * Send a message thru the Server to the UIN
  * 'text' is the message
  */
-void icq_sendmsg( UIN_T uin, const gchar *text, gboolean forced )
+void icq_sendmsg( UIN_T uin, const gchar *text, gboolean forced, gboolean resent )
 {
 	SIMPLE_MESSAGE msg;
 	net_icq_pak pak;
@@ -231,12 +233,17 @@
 		return;
 	}
 
-	new_text = cr_convert( text );
+	if (resent) {
+		new_text = g_strdup( text );
+	} else {
+		/* Add statement to personal history file */
+		add_outgoing_to_history( uin, text );
 
-	/* Add statement to personal history file */
-	add_outgoing_to_history( uin, new_text );
+		new_text = toNet( text );
+
+		rus_conv( RUS_KOI_WIN, new_text );
+	}
 
-	rus_conv( RUS_KOI_WIN, new_text );
 	if( !forced && !toggles->force && TCPSendMessage( uin, new_text) )
 	{
 		log_window_add(_("Sent Message (TCP)"), uin );
@@ -322,14 +329,20 @@
 
 	uin = ((CONTACT_PTR)data->contact->data)->uin;
 	
-	text = g_strdup_printf( "%s\xFE%s",
+	text = g_strdup_printf( "%s\n%s",
 				gtk_entry_get_text( GTK_ENTRY( data->desc ) ),
 				gtk_entry_get_text( GTK_ENTRY( data->url ) ) );
-	new_text = cr_convert( text );
-	g_free( text );
 
 	/* Add statement to personal history file */
-	add_outgoing_to_history( uin, new_text );
+	add_outgoing_to_history( uin, text );
+
+	g_free( text );
+
+	text = g_strdup_printf( "%s\xFE%s",
+				gtk_entry_get_text( GTK_ENTRY( data->desc ) ),
+				gtk_entry_get_text( GTK_ENTRY( data->url ) ) );
+	new_text = toNet( text );
+	g_free( text );
 
 	rus_conv( RUS_KOI_WIN, new_text );
 	if( TCPSendURL( uin, new_text ) )
@@ -655,6 +668,8 @@
 	net_icq_pak pak;
 	int size ;
 
+	gchar *new_about;
+
 	Word_2_Chars( pak.head.ver, ICQ_VER );
 	Word_2_Chars( pak.head.cmd, CMD_UPDATE_INFO );
 	Word_2_Chars( pak.head.seq, seq_num++ );
@@ -787,10 +802,15 @@
    
    Word_2_Chars( pak.data , META_INFO_ABOUT );
    size = 2;
-	Word_2_Chars( pak.data + size, strlen( cr_convert( our_info->about ) ) + 1 );
+
+	new_about = toNet( our_info->about );
+
+	Word_2_Chars( pak.data + size, strlen( new_about ) + 1 );
 	size += 2;
-	strcpy( pak.data + size, cr_convert( our_info->about ) );
-	size += strlen( cr_convert( our_info->about ) ) + 1;
+	strcpy( pak.data + size, new_about );
+	size += strlen( new_about ) + 1;
+
+	g_free( new_about );
 
 	SOCKWRITE( &(pak.head.ver), size + sizeof( pak.head ) - 2, "CMD_META_USER(META_INFO_ABOUT)");
 }
@@ -862,6 +882,56 @@
 	t[ cy ] = 0x00;
 	
 	return t;
+}
+
+gchar *cr_unconvert( const gchar *text )
+{
+	char *t;
+	int cx, cy;
+	
+	cy = 0;
+	for( cx = 0; cx < strlen( text ); cx ++ )
+	{
+		if( text[ cx ] == '\r' )
+			cy ++;
+	}
+	
+	t = g_malloc( strlen( text ) - cy + 1 );
+
+	cy = 0;
+	for( cx = 0; cx < strlen( text ); cx ++ )
+	{
+		if( text[ cx ] != '\r' )
+			t[ cy ++ ] = text[ cx ];
+	}
+
+	t[ cy ] = 0x00;
+	
+	return t;
+}
+
+gchar *toNet( const gchar *text )
+{
+  gchar *tmp1, *tmp2;
+
+  tmp1 = cr_convert( text );
+  tmp2 = toStringSJISfromEUC( tmp1 );
+
+  g_free( tmp1 );
+
+  return tmp2;
+}
+
+gchar *toLocal( const gchar *text )
+{
+  gchar *tmp1, *tmp2;
+
+  tmp1 = cr_unconvert( text );
+  tmp2 = toStringEUCfromSJIS( tmp1 );
+
+  g_free( tmp1 );
+
+  return tmp2;
 }
 
 void Wrinkle( void *buf, size_t len )
