summaryrefslogtreecommitdiff
path: root/BBSHTMLConfig.c
diff options
context:
space:
mode:
authorDave Hibberd <hibby@debian.org>2024-11-12 21:20:03 +0000
committerDave Hibberd <hibby@debian.org>2024-11-12 21:20:03 +0000
commit4d14474d923db3022b3074f5a5c4fb7a89ba081c (patch)
treeadfed2cd661ac45b9a91bd8345f786167fb4158d /BBSHTMLConfig.c
parent1b40c8c7b54e015f92b7fce1137a1f9c0bbed061 (diff)
parent7d1deaae3884a9ca8bdba9df5c7b317171ab3b40 (diff)
Update upstream source from tag 'upstream/6.0.24.50'
Update to upstream version '6.0.24.50' with Debian dir 3f4098912b60dfa9efe9055ce3f628a93c095c82
Diffstat (limited to 'BBSHTMLConfig.c')
-rw-r--r--BBSHTMLConfig.c43
1 files changed, 11 insertions, 32 deletions
diff --git a/BBSHTMLConfig.c b/BBSHTMLConfig.c
index d1a62ce..3234c00 100644
--- a/BBSHTMLConfig.c
+++ b/BBSHTMLConfig.c
@@ -405,41 +405,20 @@ int SendHeader(char * Reply, char * Key)
void ConvertTitletoUTF8(WebMailInfo * WebMail, char * Title, char * UTF8Title, int Len)
{
- if (WebIsUTF8(Title, (int)strlen(Title)) == FALSE)
- {
- // With Windows it is simple - convert using current codepage
- // I think the only reliable way is to convert to unicode and back
-
- int origlen = (int)strlen(Title) + 1;
-#ifdef WIN32
- WCHAR BufferW[128];
- int wlen;
- int len = origlen;
-
- wlen = MultiByteToWideChar(CP_ACP, 0, Title, len, BufferW, origlen * 2);
- len = WideCharToMultiByte(CP_UTF8, 0, BufferW, wlen, UTF8Title, origlen * 2, NULL, NULL);
-#else
- size_t left = Len - 1;
- size_t len = origlen;
-
- iconv_t * icu = WebMail->iconv_toUTF8;
-
- if (WebMail->iconv_toUTF8 == NULL)
- icu = WebMail->iconv_toUTF8 = iconv_open("UTF-8//IGNORE", "CP1252");
+ Len = strlen(Title);
- if (icu == (iconv_t)-1)
- {
- strcpy(UTF8Title, Title);
- WebMail->iconv_toUTF8 = NULL;
- return;
- }
-
- char * orig = UTF8Title;
+ if (WebIsUTF8(Title, Len) == FALSE)
+ {
+ int code = TrytoGuessCode(Title, Len);
- iconv(icu, NULL, NULL, NULL, NULL); // Reset State Machine
- iconv(icu, &Title, &len, (char ** __restrict__)&UTF8Title, &left);
+ if (code == 437)
+ Len = Convert437toUTF8(Title, Len, UTF8Title);
+ else if (code == 1251)
+ Len = Convert1251toUTF8(Title, Len, UTF8Title);
+ else
+ Len = Convert1252toUTF8(Title, Len, UTF8Title);
-#endif
+ UTF8Title[Len] = 0;
}
else
strcpy(UTF8Title, Title);