diff options
| author | Wilmer van der Gaast <wilmer@gaast.net> | 2006-03-31 10:53:53 +0200 | 
|---|---|---|
| committer | Wilmer van der Gaast <wilmer@gaast.net> | 2006-03-31 10:53:53 +0200 | 
| commit | d783e48a831cf5058e2307a382e7e95a06680289 (patch) | |
| tree | a1528011d56d4213084d4f6f617c75c3144c13fb | |
| parent | 755ae5b84f4b0806e339a6e1503406bf43028fd5 (diff) | |
irc_vawrite() does charset conversion now. Next step: Do it for incoming IRC
traffic, and get rid of most other iconv() calls.
| -rw-r--r-- | irc.c | 21 | 
1 files changed, 15 insertions, 6 deletions
@@ -562,16 +562,25 @@ void irc_write( irc_t *irc, char *format, ... )  void irc_vawrite( irc_t *irc, char *format, va_list params )  {  	int size; -	char line[IRC_MAX_LINE]; -	 +	char line[IRC_MAX_LINE+1], *cs; +		  	if( irc->quit )  		return; - -	g_vsnprintf( line, IRC_MAX_LINE - 3, format, params ); - +	 +	line[IRC_MAX_LINE] = 0; +	g_vsnprintf( line, IRC_MAX_LINE - 2, format, params ); +	  	strip_newlines( line ); +	if( ( cs = set_getstr( irc, "charset" ) ) ) +	{ +		char conv[IRC_MAX_LINE+1]; +		 +		conv[IRC_MAX_LINE] = 0; +		if( do_iconv( "UTF-8", cs, line, conv, 0, IRC_MAX_LINE - 2 ) != -1 ) +			strcpy( line, conv ); +	}  	strcat( line, "\r\n" ); - +	  	if( irc->sendbuffer != NULL ) {  		size = strlen( irc->sendbuffer ) + strlen( line );  		irc->sendbuffer = g_renew ( char, irc->sendbuffer, size + 1 );  | 
