attempt to use libiconv to convert cp437 to utf8

This commit is contained in:
Andrew Pamment 2017-03-31 07:39:04 +10:00
parent 0b80fff93e
commit 593042c06a
5 changed files with 16 additions and 8 deletions

View File

@ -5,7 +5,7 @@ JAMLIB = deps/jamlib/jamlib.a
ZMODEM = deps/Xmodem/libzmodem.a
LUA = deps/lua/liblua.a
B64 = deps/libb64-1.2/src/libb64.a
MICROHTTPD=-lmicrohttpd
MICROHTTPD=-lmicrohttpd -liconv
ODOORS = deps/odoors/libs-`uname -s`/libODoors.a
JSMN = deps/jsmn/libjsmn.a
CDK = deps/cdk-5-20161210/libcdk.a

View File

@ -5,7 +5,7 @@ JAMLIB = deps/jamlib/jamlib.a
ZMODEM = deps/Xmodem/libzmodem.a
LUA = deps/lua/liblua.a
B64 = deps/libb64-1.2/src/libb64.a
MICROHTTPD=-lmicrohttpd
MICROHTTPD=-lmicrohttpd -liconv
ODOORS = deps/odoors/libs-`uname -s`/libODoors.a
JSMN = deps/jsmn/libjsmn.a
CDK = deps/cdk-5-20161210/libcdk.a

View File

@ -5,7 +5,7 @@ JAMLIB = deps/jamlib/jamlib.a
ZMODEM = deps/Xmodem/libzmodem.a
LUA = deps/lua/liblua.a
B64 = deps/libb64-1.2/src/libb64.a
MICROHTTPD=-lmicrohttpd
MICROHTTPD=-lmicrohttpd -liconv
ODOORS = deps/odoors/libs-`uname -s`/libODoors.a
JSMN = deps/jsmn/libjsmn.a
CDK = deps/cdk-5-20161210/libcdk.a

View File

@ -5,7 +5,7 @@ JAMLIB = deps/jamlib/jamlib.a
ZMODEM = deps/Xmodem/libzmodem.a
LUA = deps/lua/liblua.a
B64 = deps/libb64-1.2/src/libb64.a
MICROHTTPD=-lmicrohttpd
MICROHTTPD=-lmicrohttpd -liconv
ODOORS = deps/odoors/libs-`uname -s`/libODoors.a
JSMN = deps/jsmn/libjsmn.a
CDK = deps/cdk-5-20161210/libcdk.a

View File

@ -7,6 +7,7 @@
#ifdef __FreeBSD__
#include <sys/stat.h>
#endif
#include <iconv.h>
#include "bbs.h"
#include "jamlib/jam.h"
@ -269,9 +270,10 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
char buffer[4096];
int chars;
int i;
iconv_t ic;
char *aha_text;
char *aha_out;
char *aha_cp437;
if (conference < 0 || conference >= conf.mail_conference_count || area < 0 || area >= conf.mail_conferences[conference]->mail_area_count) {
return NULL;
@ -465,10 +467,16 @@ char *www_msgs_messageview(struct user_record *user, int conference, int area, i
len += strlen(buffer);
aha_text = (char *)malloc(jmh.TxtLen + 1);
memcpy(aha_text, body, jmh.TxtLen);
aha_text[jmh.TxtLen] = '\0';
aha_text = (char *)malloc(jmh.TxtLen + 1);
aha_cp437 = (char *)malloc(jmh.TxtLen + 1);
memcpy(aha_cp437, body, jmh.TxtLen);
aha_cp437[jmh.TxtLen] = '\0';
ic = iconv_open("UTF-8//TRANSLIT", "CP437");
iconv(ic, &aha_cp437, jmh.TxtLen, &aha_text, jmh.TxtLen);
iconv_close(ic);
aha_out = aha(aha_text);
while (len + strlen(aha_out) > max_len - 1) {
max_len += 4096;