AmendHub

Download:

jcs

/

wallops

/

amendments

/

113

chatter: Run printed messages through utf8_to_macroman_string

I'm not sure if it's worth doing MacRoman to UTF-8 on the way out.

jcs made amendment 113 2 months ago
--- chatter.c Mon Sep 16 16:43:39 2024 +++ chatter.c Mon Sep 16 17:20:33 2024 @@ -21,6 +21,7 @@ #include "irc.h" #include "settings.h" #include "util.h" +#include "utf8.h" #define NICK_LIST_WIDTH 75 #define CHATTER_SCRAP_ELEMENTS 20 @@ -1094,7 +1095,7 @@ size_t chatter_printf(struct chatter *chatter, struct irc_connection *conn, char *dest_tab, const char *format, ...) { - static char buf[600], buf_out[600]; + static char buf[600], buf_out[600], conv_buf[601]; struct chatter_tab *tab = chatter->current_tab, *ttab; StScrpRec *scrp_rec; ScrpSTElement *scrp_ele, *prev_scrp_ele; @@ -1130,6 +1131,8 @@ chatter_printf(struct chatter *chatter, struct irc_con len += vsnprintf(buf + len, sizeof(buf) - len, format, argptr); va_end(argptr); + len = utf8_to_macroman_string(buf, len, conv_buf); + if (scrp_rec_h == NULL) { scrp_rec_h = xNewHandle(4 + (20 * CHATTER_SCRAP_ELEMENTS)); HLock(scrp_rec_h); @@ -1150,7 +1153,7 @@ chatter_printf(struct chatter *chatter, struct irc_con scrp_ele->scrpFace = 0; for (n = 0, buf_out_len = 0, in_this_style = 0; n < len; n++) { - if (!stop_formatting && buf[n] == '$') { + if (!stop_formatting && conv_buf[n] == '$') { if (in_this_style > 0) { scrp_rec->scrpNStyles++; if (scrp_rec->scrpNStyles >= CHATTER_SCRAP_ELEMENTS) @@ -1163,7 +1166,7 @@ chatter_printf(struct chatter *chatter, struct irc_con } scrp_ele->scrpStartChar = buf_out_len; - switch (buf[n + 1]) { + switch (conv_buf[n + 1]) { case 'B': scrp_ele->scrpFace |= bold | condense; break; @@ -1190,7 +1193,7 @@ chatter_printf(struct chatter *chatter, struct irc_con n++; continue; } - buf_out[buf_out_len++] = buf[n]; + buf_out[buf_out_len++] = conv_buf[n]; in_this_style++; }