More Chinese characters support

This commit is contained in:
Michiel Broek 2005-04-03 14:12:12 +00:00
parent a1d01ff815
commit f9e170dd72
7 changed files with 55 additions and 4 deletions

View File

@ -19,6 +19,13 @@ v0.71.2 16-Jan-2005
that host aka's (node /0) were not presented to the remote. that host aka's (node /0) were not presented to the remote.
(thanks Przemyslaw Kwiatkowski). (thanks Przemyslaw Kwiatkowski).
mbsebbs:
When a message is posted by a user, the CHRS kludge of the user
is used in the message, not the area setting.
When a user logs in, the users locale (guessed value from his
characterset) is set. Experimental to see if libc functions will
support Chinese characters.
mbfido: mbfido:
Empty *.msg netmails for our own system are dropped with and Empty *.msg netmails for our own system are dropped with and
logged (just like received empty netmails). Empty netmails to logged (just like received empty netmails). Empty netmails to

View File

@ -127,6 +127,38 @@ char *getchrs(int val)
} }
/*
* Experimental table that should translate from the user selected
* charset to a locale. This is not the right way to do, the best
* thing is to store each bbs users locale instead and then lookup
* his characterset using standard library calls.
*
* This is one of the things the bbs world never saw coming, in the
* "good" old days bbses were almost allways called local. Thanks
* to the internet bbs users are now all over the world.
*/
char *getlocale(int val)
{
switch (val) {
case FTNC_NONE: return (char *)"C";
case FTNC_CP437: return (char *)"en_US";
case FTNC_CP850: return (char *)"en_US";
case FTNC_CP865: return (char *)"sv_SE";
case FTNC_CP866: return (char *)"ru_RU";
case FTNC_CP852: return (char *)"cs_CZ";
case FTNC_CP895: return (char *)"cs_CZ";
case FTNC_LATIN_1: return (char *)"en_US";
case FTNC_LATIN_2: return (char *)"cs_CZ";
case FTNC_MAC: return (char *)"en_US";
case FTNC_KOI8_R: return (char *)"ru_RU.koi8r";
case FTNC_CP936: return (char *)"zh_CN.gbk";
default: return (char *)"C";
}
}
char *getchrsdesc(int val) char *getchrsdesc(int val)
{ {
switch (val) { switch (val) {

View File

@ -93,6 +93,8 @@
#if !defined(__ppc__) #if !defined(__ppc__)
#include <sys/poll.h> #include <sys/poll.h>
#endif #endif
#include <locale.h>
#include <langinfo.h>
/* used to use #elif, but native braindead hpux 9.00 c compiler didn't /* used to use #elif, but native braindead hpux 9.00 c compiler didn't
* * understand it */ * * understand it */
@ -2538,6 +2540,7 @@ typedef struct st_charset_table {
char *getchrs(int); /* Return characterset name */ char *getchrs(int); /* Return characterset name */
char *getlocale(int); /* Return locale name */
char *getchrsdesc(int); /* Return characterset description */ char *getchrsdesc(int); /* Return characterset description */
CharsetTable *charset_table_new(void); /* Add table to linked list */ CharsetTable *charset_table_new(void); /* Add table to linked list */
CharsetAlias *charset_alias_new(void); /* Add alias to linked list */ CharsetAlias *charset_alias_new(void); /* Add alias to linked list */

View File

@ -1052,6 +1052,8 @@ void Chg_Charset()
exitinfo.Charset = i; exitinfo.Charset = i;
Syslog('+', "New character set %s", getchrs(exitinfo.Charset)); Syslog('+', "New character set %s", getchrs(exitinfo.Charset));
WriteExitinfo(); WriteExitinfo();
setlocale(LC_CTYPE, getlocale(exitinfo.Charset));
Syslog('b', "setlocale(LC_CTYPE, NULL) returns \"%s\"", printable(setlocale(LC_CTYPE, NULL), 0));
Enter(2); Enter(2);
colour(LIGHTGREEN, BLACK); colour(LIGHTGREEN, BLACK);
/* Character set now set to: */ /* Character set now set to: */

View File

@ -46,8 +46,6 @@
#include "ttyio.h" #include "ttyio.h"
#include "openport.h" #include "openport.h"
#include <locale.h>
#include <langinfo.h>
extern int do_quiet; /* Logging quiet flag */ extern int do_quiet; /* Logging quiet flag */
@ -228,7 +226,7 @@ int main(int argc, char **argv)
/* /*
* Some debugging for me * Some debugging for me
*/ */
Syslog('b', "setlocale() returns \"%s\"", printable(setlocale(LC_ALL, NULL), 0)); Syslog('b', "setlocale(LC_ALL, NULL) returns \"%s\"", printable(setlocale(LC_ALL, NULL), 0));
/* Next is not usefull */ /* Next is not usefull */
Syslog('b', "nl_langinfo(LC_CTYPE) returns \"%s\"", printable(nl_langinfo(LC_CTYPE), 0)); Syslog('b', "nl_langinfo(LC_CTYPE) returns \"%s\"", printable(nl_langinfo(LC_CTYPE), 0));

View File

@ -219,7 +219,12 @@ void Add_Headkludges(faddr *dest, int IsReply)
break; break;
} }
if (msgs.Charset != FTNC_NONE) { /*
* Set the right charset kludge
*/
if (exitinfo.Charset != FTNC_NONE) {
sprintf(temp, "\001CHRS: %s", getchrs(exitinfo.Charset));
} else if (msgs.Charset != FTNC_NONE) {
sprintf(temp, "\001CHRS: %s", getchrs(msgs.Charset)); sprintf(temp, "\001CHRS: %s", getchrs(msgs.Charset));
} else { } else {
sprintf(temp, "\001CHRS: %s", getchrs(FTNC_LATIN_1)); sprintf(temp, "\001CHRS: %s", getchrs(FTNC_LATIN_1));

View File

@ -53,6 +53,7 @@
#include "ttyio.h" #include "ttyio.h"
extern int sock; extern int sock;
extern pid_t mypid; extern pid_t mypid;
char *StartTime = NULL; char *StartTime = NULL;
@ -463,6 +464,9 @@ void user()
Chg_Charset(); Chg_Charset();
} }
setlocale(LC_CTYPE, getlocale(exitinfo.Charset));
Syslog('b', "setlocale(LC_CTYPE, NULL) returns \"%s\"", printable(setlocale(LC_CTYPE, NULL), 0));
GetLastUser(); GetLastUser();
StartTime = xstrcpy(GetLocalHM()); StartTime = xstrcpy(GetLocalHM());
ChangeHomeDir(exitinfo.Name, exitinfo.Email); ChangeHomeDir(exitinfo.Name, exitinfo.Email);