Commit d2df590f authored by rswindell's avatar rswindell
Browse files

Created new SMBLIB function: smb_msg_is_utf8() which reutrns TRUE if the passed

message body is UTF-8 encoded. This works for either messages received via FTN
(with the "CHRS: UTF-8" control paragraph) or MIME-encoded messages (e.g.
Internet e-mail).

This is to be used by things to display messages. If the viewer (e.g. user's
terminal) supports UTF-8, just send through as-is. If not, translation (e.g. to
CP437) or filtering may be needed.
parent 457c7745
......@@ -873,7 +873,7 @@ static void set_convenience_ptr(smbmsg_t* msg, uint16_t hfield_type, void* hfiel
p += 13;
SKIP_WHITESPACE(p);
msg->content_type = p;
smb_parse_content_type(p, &msg->text_subtype, &msg->text_charset);
smb_parse_content_type(p, &(msg->text_subtype), &(msg->text_charset));
break;
}
break;
......@@ -1693,6 +1693,17 @@ BOOL SMBCALL smb_msg_is_from(smbmsg_t* msg, const char* name, enum smb_net_type
}
}
BOOL SMBCALL smb_msg_is_utf8(smbmsg_t* msg)
{
for(int i=0; i < msg->total_hfields; i++) {
switch(msg->hfield[i].type) {
case FIDOCTRL:
if(strncmp(msg->hfield_dat[i], "CHRS: UTF-8", 11) == 0)
return TRUE;
}
}
return msg->text_charset != NULL && stricmp(msg->text_charset, "utf-8") == 0;
}
uint16_t SMBCALL smb_voted_already(smb_t* smb, uint32_t msgnum, const char* name, enum smb_net_type net_type, void* net_addr)
{
......
......@@ -188,6 +188,7 @@ SMBEXPORT uint32_t SMBCALL smb_first_in_thread(smb_t*, smbmsg_t*, msghdr_t*);
SMBEXPORT uint32_t SMBCALL smb_next_in_thread(smb_t*, smbmsg_t*, msghdr_t*);
SMBEXPORT uint32_t SMBCALL smb_last_in_branch(smb_t*, smbmsg_t*);
SMBEXPORT uint32_t SMBCALL smb_last_in_thread(smb_t*, smbmsg_t*);
SMBEXPORT BOOL SMBCALL smb_msg_is_utf8(smbmsg_t*);
/* smbadd.c */
SMBEXPORT int SMBCALL smb_addmsg(smb_t* smb, smbmsg_t* msg, int storage, long dupechk_hashes
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment