From 61eba4600c6dce2d28bbf34a82f9883e633d74ef Mon Sep 17 00:00:00 2001 From: chombier <> Date: Fri, 22 Nov 2002 16:45:54 +0000 Subject: [PATCH] added Big-5 translation --- macssh/source/parse/translate.c | 29 ++++++++++++++++++++++++----- macssh/source/parse/translate.h | 9 +++++---- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/macssh/source/parse/translate.c b/macssh/source/parse/translate.c index 7435d61..9c27a67 100755 --- a/macssh/source/parse/translate.c +++ b/macssh/source/parse/translate.c @@ -49,10 +49,10 @@ BytePtr DefaultTable, FTPinTable, FTPoutTable; -Handle transTablesHdl; -short nNational = 0; -short gTableCount; - +Handle transTablesHdl; +short nNational = 0; +short gTableCount = 0; +TextEncoding gLocalEncoding = 0; short transBuffer(short oldtable, short newtable) /* translate entire buffer */ { @@ -176,6 +176,8 @@ void BuildTranslateMenu(MenuHandle whichMenu) SetMenuItemText(whichMenu, gTableCount + 3, "\pEUC-JP"); AppendMenu(whichMenu, "\p "); SetMenuItemText(whichMenu, gTableCount + 4, "\pShift-JIS"); + AppendMenu(whichMenu, "\p "); + SetMenuItemText(whichMenu, gTableCount + 5, "\pBig-5"); /* tests */ /* AppendMenu(whichMenu, "\p "); @@ -254,8 +256,12 @@ static void trTECInit() return; if (FindSymbol( connID, "\pTECCreateConverter", NULL, NULL ) != noErr) return; - nNational = 3; // 3 hard-coded translations actually + nNational = 4; // 4 hard-coded translations actually //nNational = 7; // tests + + // use current system settings for local encoding + UpgradeScriptInfoToTextEncoding(smSystemScript, kTextLanguageDontCare, + kTextRegionDontCare, NULL, &gLocalEncoding); #endif } @@ -334,6 +340,12 @@ void switchintranslation(WindRec *tw, short national, short charset) inputEncoding = kTextEncodingShiftJIS; outputEncoding = kTextEncodingMacJapanese; break; + case kTRBig5: + cname = "kTRBig5"; + inputEncoding = kTextEncodingBig5; + outputEncoding = (gLocalEncoding == 0) ? kTextEncodingMacChineseTrad : gLocalEncoding; + break; + case kTRJISX0208_1978: cname = "kTRJISX0208_1978"; inputEncoding = kTextEncodingISO_2022_JP; @@ -496,6 +508,11 @@ void switchouttranslation(WindRec *tw, short national, short charset) inputEncoding = kTextEncodingMacJapanese; outputEncoding = kTextEncodingShiftJIS; break; + case kTRBig5: + cname = "kTRBig5"; + inputEncoding = (gLocalEncoding == 0) ? kTextEncodingMacChineseTrad : gLocalEncoding; + outputEncoding = kTextEncodingBig5; + break; case kTRJISX0208_1978: cname = "kTRJISX0208_1978"; @@ -731,6 +748,7 @@ int trbuf_nat_mac(WindRec *tw, unsigned char *buf, long *len, unsigned char *out break; case kTREUC_JP: case kTRShiftJIS: + case kTRBig5: //case kTRJISX0208_1978: //case kTRJISX0208_1983: case kTRJISX0212_1990: @@ -775,6 +793,7 @@ int trbuf_mac_nat(WindRec *tw, unsigned char *buf, long *len, unsigned char *out case kTRJIS: case kTREUC_JP: case kTRShiftJIS: + case kTRBig5: case kTRJISX0208_1978: case kTRJISX0208_1983: case kTRJISX0212_1990: diff --git a/macssh/source/parse/translate.h b/macssh/source/parse/translate.h index 2cf9cfe..dd98fc2 100644 --- a/macssh/source/parse/translate.h +++ b/macssh/source/parse/translate.h @@ -2,10 +2,11 @@ #define kTRJIS -1 #define kTREUC_JP -2 #define kTRShiftJIS -3 -#define kTRJISX0208_1978 -4 -#define kTRJISX0208_1983 -5 -#define kTRJISX0212_1990 -6 -#define kTRJISX0201_76kana -7 +#define kTRBig5 -4 +#define kTRJISX0208_1978 -5 +#define kTRJISX0208_1983 -6 +#define kTRJISX0212_1990 -7 +#define kTRJISX0201_76kana -8 /* character sets for ISO-2022-JP (kTRJIS) */ enum {