Author: Andrey Smirnov

--- /dev/null
+++ b/misc/maptabs/cp866__koi8-r
@@ -0,0 +1,131 @@
+#       Channel map for translation cp866 (PC-alternate) codes to koi8-r codes
+#       (Russian language) according to RFC 1489
+#in  out
+0x80 0xE1
+0x81 0xE2
+0x82 0xF7
+0x83 0xE7
+0x84 0xE4
+0x85 0xE5
+0x86 0xF6
+0x87 0xFA
+0x88 0xE9
+0x89 0xEA
+0x8A 0xEB
+0x8B 0xEC
+0x8C 0xED
+0x8D 0xEE
+0x8E 0xEF
+0x8F 0xF0
+0x90 0xF2
+0x91 0xF3
+0x92 0xF4
+0x93 0xF5
+0x94 0xE6
+0x95 0xE8
+0x96 0xE3
+0x97 0xFE
+0x98 0xFB
+0x99 0xFD
+0x9A 0xFF
+0x9B 0xF9
+0x9C 0xF8
+0x9D 0xFC
+0x9E 0xE0
+0x9F 0xF1
+0xA0 0xC1
+0xA1 0xC2
+0xA2 0xD7
+0xA3 0xC7
+0xA4 0xC4
+0xA5 0xC5
+0xA6 0xD6
+0xA7 0xDA
+0xA8 0xC9
+0xA9 0xCA
+0xAA 0xCB
+0xAB 0xCC
+0xAC 0xCD
+0xAD 0xCE
+0xAE 0xCF
+0xAF 0xD0
+0xB0 0x90
+0xB1 0x91
+0xB2 0x92
+0xB3 0x81
+0xB4 0x87
+0xB5 0xB2
+0xB6 0xB4
+0xB7 0xA7
+0xB8 0xA6
+0xB9 0xB5
+0xBA 0xA1
+0xBB 0xA8
+0xBC 0xAE
+0xBD 0xAD
+0xBE 0xAC
+0xBF 0x83
+0xC0 0x84
+0xC1 0x89
+0xC2 0x88
+0xC3 0x86
+0xC4 0x80
+0xC5 0x8A
+0xC6 0xAF
+0xC7 0xB0
+0xC8 0xAB
+0xC9 0xA5
+0xCA 0xBB
+0xCB 0xB8
+0xCC 0xB1
+0xCD 0xA0
+0xCE 0xBE
+0xCF 0xB9
+0xD0 0xBA
+0xD1 0xB6
+0xD2 0xB7
+0xD3 0xAA
+0xD4 0xA9
+0xD5 0xA2
+0xD6 0xA4
+0xD7 0xBD
+0xD8 0xBC
+0xD9 0x85
+0xDA 0x82
+0xDB 0x8D
+0xDC 0x8C
+0xDD 0x8E
+0xDE 0x8F
+0xDF 0x8B
+0xE0 0xD2
+0xE1 0xD3
+0xE2 0xD4
+0xE3 0xD5
+0xE4 0xC6
+0xE5 0xC8
+0xE6 0xC3
+0xE7 0xDE
+0xE8 0xDB
+0xE9 0xDD
+0xEA 0xDF
+0xEB 0xD9
+0xEC 0xD8
+0xED 0xDC
+0xEE 0xC0
+0xEF 0xD1
+0xF0 0xB3
+0xF1 0xA3
+0xF2 0x99
+0xF3 0x98
+0xF4 0x93
+0xF5 0x9B
+0xF6 0x9F
+0xF7 0x97
+0xF8 0x9C
+0xF9 0x95
+0xFA 0x9E
+0xFB 0x96
+0xFC 0xBF
+0xFD 0x9D
+0xFE 0x94
+0xFF 0x9A
--- /dev/null
+++ b/misc/maptabs/koi8-r__cp866
@@ -0,0 +1,134 @@
+#       Channel map for translation koi8-r codes to cp866 (PC-alternative)
+#       codes (Russian language) according to RFC 1489 expect
+#       due to fidonet wieredness, capital Russian EN translates to
+#       latin 'H' (0x8D code is soft CR in fidonet).
+#in  out
+0x80 0xC4
+0x81 0xB3
+0x82 0xDA
+0x83 0xBF
+0x84 0xC0
+0x85 0xD9
+0x86 0xC3
+0x87 0xB4
+0x88 0xC2
+0x89 0xC1
+0x8A 0xC5
+0x8B 0xDF
+0x8C 0xDC
+0x8D 0xDB
+0x8E 0xDD
+0x8F 0xDE
+0x90 0xB0
+0x91 0xB1
+0x92 0xB2
+0x93 0xF4
+0x94 0xFE
+0x95 0xF9
+0x96 0xFB
+0x97 0xF7
+0x98 0xF3
+0x99 0xF2
+0x9A 0xFF
+0x9B 0xF5
+0x9C 0xF8
+0x9D 0xFD
+0x9E 0xFA
+0x9F 0xF6
+0xA0 0xCD
+0xA1 0xBA
+0xA2 0xD5
+0xA3 0xF1
+0xA4 0xD6
+0xA5 0xC9
+0xA6 0x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code==CHRS_MACINTOSH) && (toftnchar!=CHRS_NOTSET))
 		return toftnchar;
 	else if (code==CHRS_MACINTOSH) return CHRS_ISO_8859_1;
+        else if (code==CHRS_KOI8_R) return CHRS_CP866; /* R50 echos are *always* in cp866 - ams */
 	else if ((toftnchar!=CHRS_NOTSET) && (code==defaultrfcchar)) 
 		return toftnchar;
 	else if (code==CHRS_UTF_7||code==CHRS_UTF_8) return CHRS_AUTODETECT;
@@ -210,6 +211,7 @@ char *p;
 	else if (strncasecmp(p,"CP852",5) == 0) code=CHRS_CP852;
 	else if (strncasecmp(p,"CP862",5) == 0) code=CHRS_CP862;
 	else if (strncasecmp(p,"CP866",5) == 0) code=CHRS_CP866; /* ??? */
+	else if (strncasecmp(p,"FIDO7",5) == 0) code=CHRS_CP866; /* also used in R50 of Z2 */
 	else if (strncasecmp(p,"CP895",5) == 0) code=CHRS_CP895;
 	else if (strncasecmp(p,"CP932",5) == 0) code=CHRS_SJIS;
 	else if (strncasecmp(p,"CP942",5) == 0) code=CHRS_SJIS;
--- a/ifgate/charconv.h
+++ b/ifgate/charconv.h
@@ -39,6 +39,7 @@ void utf8_to_eight(char *in, char **out,
 #define CP862__ISO_8859_8	"cp862__iso-8859-8"
 #define CP866__ISO_8859_5	"mik__iso-8859-5"
 #define CP866__KOI8		"cp866__koi8"
+#define CP866__KOI8_R		"cp866__koi8-r"
 #define CP895__CP437            "cp895__cp437"
 #define CP895__ISO_8859_2       "cp895__iso-8859-2"
 #define FIDOMAZOVIA__CP852	"fidomazovia__cp852"
@@ -58,6 +59,7 @@ void utf8_to_eight(char *in, char **out,
 #define ISO_8859_8__CP424	"iso-8859-8__cp424"
 #define ISO_8859_8__CP862	"iso-8859-8__cp862"
 #define KOI8__CP866		"koi8__cp866"
+#define KOI8_R__CP866		"koi8-r__cp866"
 #define KOI8__ISO_8859_5	"koi8__iso-8859-5"
 #define KOI8__MIK_CYR		"koi8__mik"
 #define MACINTOSH__CP437	"mac__cp437"
--- a/ifgate/charconv.c
+++ b/ifgate/charconv.c
@@ -162,7 +162,7 @@ void kconv(char *in, char **out, int inc
       case CHRS_CP866 :
 	switch (outcode) {
 	  case CHRS_ISO_8859_5 : eight2eight(in,out,CP866__ISO_8859_5); break;
-          case CHRS_KOI8_R :
+	  case CHRS_KOI8_R :	 eight2eight(in,out,CP866__KOI8_R); break;
           case CHRS_KOI8_U :	 eight2eight(in,out,CP866__KOI8); break;
           default :		 noconv(in,out); break;
         }
@@ -321,6 +321,13 @@ void kconv(char *in, char **out, int inc
         }
         break;
       case CHRS_KOI8_R :
+        switch (outcode) {
+          case CHRS_CP866 :	 eight2eight(in,out,KOI8_R__CP866); break;
+          case CHRS_ISO_8859_5 : eight2eight(in,out,KOI8__ISO_8859_5); break;
+          case CHRS_MIK_CYR :	 eight2eight(in,out,KOI8__MIK_CYR); break;
+          default :		 noconv(in,out); break;
+	}
+        break;
       case CHRS_KOI8_U :
         switch (outcode) {
           case CHRS_CP866 :	 eight2eight(in,out,KOI8__CP866); break;
