diff --git a/cfgs/config/advanced.cfg b/cfgs/config/advanced.cfg
index 4e8d9ee..c215203 100644
--- a/cfgs/config/advanced.cfg
+++ b/cfgs/config/advanced.cfg
@@ -1423,6 +1423,11 @@ XLATEXPORT IBMPC
;XLATLOCALSET CP850
XLATLOCALSET IBMPC
+// Used to translate latin A-Za-z to local charset if one of neighbours
+// is from local charset too.
+// ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+;LatinToLocal ABCDEFGНIJKLMNOPQRSTUVWXYZabcdefghijklmnoрqrstuvwxуz ;cp866 - H,p,y
+
----------------------------------------------------------------------
-- MESSAGE ATTRIBUTE DEFAULTS
diff --git a/cfgs/config/advanced.rus b/cfgs/config/advanced.rus
index d067388..be969a7 100644
--- a/cfgs/config/advanced.rus
+++ b/cfgs/config/advanced.rus
@@ -1669,6 +1669,13 @@ XlatCharSet CP850 ASCII 850_ASC.chs
;XlatLocalSet KOI8-R
XlatLocalSet CP866
+// Этот кейворд позволяет делать обратную замену латинских букв на русские.
+// Замена будет делаться только тех латинских букв, что имеют по соседству
+// буквы локальной кодировки.
+// ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+;LatinToLocal ABCDEFGНIJKLMNOPQRSTUVWXYZabcdefghijklmnoрqrstuvwxуz ;cp866 - H,p,y
+
+
----------------------------------------------------------------------
-- АТРИБУТЫ СООБЩЕНИЙ
diff --git a/docs/notework.txt b/docs/notework.txt
index 2a7b915..b1f8eab 100644
--- a/docs/notework.txt
+++ b/docs/notework.txt
@@ -10,6 +10,10 @@ ______________________________________________________________________
Notes for GoldED+ 1.1.5, /snapshot/
______________________________________________________________________
++ New config file token LatinToLocal.
+ Used to translate latin A-Za-z to local charset if one of neighbours
+ is from local charset too.
+
+ New config file token AreaRecycleBin . GoldEd will move deleted
messages to , if this token is defined.
diff --git a/golded3/gccfgg.cpp b/golded3/gccfgg.cpp
index 472f330..41d83f3 100644
--- a/golded3/gccfgg.cpp
+++ b/golded3/gccfgg.cpp
@@ -739,6 +739,7 @@ CfgGed::CfgGed() {
internetrfcbody = 0;
internetviagate = false;
keybmode = KEYB_POLL;
+ latin2local = false;
logformat = 0;
locationdelimiter = " \x1A ";
menumarked = MODE_DONT;
diff --git a/golded3/gccfgg.h b/golded3/gccfgg.h
index d37dfc5..740f55e 100644
--- a/golded3/gccfgg.h
+++ b/golded3/gccfgg.h
@@ -240,6 +240,7 @@ const word CRC_KEYBMODE = 0xE8F2;
const word CRC_KEYBSTACK = 0x5F23;
const word CRC_KLUDGE = 0xA600;
const word CRC_KLUDGECHRS = 0x0EEF;
+const word CRC_LATINTOLOCAL = 0x9397;
const word CRC_LOADLANGUAGE = 0x9F1B;
const word CRC_LOCATIONALIAS = 0x1B5F;
const word CRC_LOCATIONDELIMITER= 0x5083;
diff --git a/golded3/gccfgg0.cpp b/golded3/gccfgg0.cpp
index 2457a8e..f03b283 100644
--- a/golded3/gccfgg0.cpp
+++ b/golded3/gccfgg0.cpp
@@ -412,6 +412,7 @@ SwitchK:
SwitchL:
switch(crc) {
+ case CRC_LATINTOLOCAL : CfgLatintolocal (); break;
case CRC_LOADLANGUAGE : CfgLoadlanguage (); break;
case CRC_LOCATIONALIAS : CfgLocationalias (); break;
case CRC_LOCATIONDELIMITER: CfgLocationdelimiter(); break;
diff --git a/golded3/gccfgg5.cpp b/golded3/gccfgg5.cpp
index 7a8deae..5b612b4 100644
--- a/golded3/gccfgg5.cpp
+++ b/golded3/gccfgg5.cpp
@@ -308,6 +308,20 @@ void CfgKludge() {
// ------------------------------------------------------------------
+void CfgLatintolocal()
+{
+ memset(CFG->latintolocal, 0, sizeof(CFG->latintolocal));
+ CFG->latin2local = true;
+
+ char *ptr = val, chr;
+ for (chr = 'A'; chr <= 'Z'; chr++, ptr++)
+ CFG->latintolocal[chr] = *ptr;
+ for (chr = 'a'; chr <= 'z'; chr++, ptr++)
+ CFG->latintolocal[chr] = *ptr;
+}
+
+// ------------------------------------------------------------------
+
void CfgLoadlanguage() {
Path buf;
diff --git a/golded3/gcprot.h b/golded3/gcprot.h
index fe9ab10..59c3fc5 100644
--- a/golded3/gcprot.h
+++ b/golded3/gcprot.h
@@ -229,6 +229,7 @@ void CfgKeybmode ();
void CfgKeybstack ();
void CfgKludge ();
void CfgKludgechrs ();
+void CfgLatintolocal ();
void CfgLoadlanguage ();
void CfgLocationalias ();
void CfgLocationdelimiter();
diff --git a/golded3/gecfgg.h b/golded3/gecfgg.h
index d39009b..d94bc92 100644
--- a/golded3/gecfgg.h
+++ b/golded3/gecfgg.h
@@ -256,6 +256,8 @@ public:
int keybmode;
char keybstack[80]; // keybuf[80];
gstrarray kludge;
+ bool latin2local;
+ char latintolocal[256];
Path loadlanguage;
GStrBag2 locationalias;
std::string locationdelimiter;
diff --git a/golded3/geline.cpp b/golded3/geline.cpp
index edcb953..47221d5 100644
--- a/golded3/geline.cpp
+++ b/golded3/geline.cpp
@@ -1680,6 +1680,51 @@ void ScanKludges(GMsg* msg, int getvalue) {
}
+// ------------------------------------------------------------------
+
+void Latin2Local(char *str)
+{
+ if (!CFG->latin2local) return;
+ for (size_t i = 0; str[i]; i++)
+ {
+ byte chr = str[i];
+ byte xch = CFG->latintolocal[chr];
+
+ if (xch && (xch != chr))
+ {
+ byte left = i ? str[i-1] : 0;
+ byte right = str[i+1];
+
+ if (((left >= 0x80) && (toupper(left) != tolower(left))) ||
+ ((right >= 0x80) && (toupper(right) != tolower(right))))
+ {
+ str[i] = xch;
+
+ for (size_t j = i-1; j < i; j--)
+ {
+ chr = str[j];
+ xch = CFG->latintolocal[chr];
+
+ if (xch && (xch != chr))
+ {
+ left = j ? str[j-1] : 0;
+ right = str[j+1];
+
+ if (((left >= 0x80) && (toupper(left) != tolower(left))) ||
+ ((right >= 0x80) && (toupper(right) != tolower(right))))
+ {
+ str[j] = xch;
+ }
+ else
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
+
// ------------------------------------------------------------------
char* XlatStr(char* dest, const char* src, int level, Chs* chrtbl, int qpencoded, bool i51) {
diff --git a/golded3/gelmsg.cpp b/golded3/gelmsg.cpp
index 995f1c0..002e67e 100644
--- a/golded3/gelmsg.cpp
+++ b/golded3/gelmsg.cpp
@@ -107,6 +107,15 @@ int Area::LoadMsg(GMsg* msg, uint32_t msgno, int margin, int mode) {
if(not (msg->attr.uns() and not msg->attr.rcv()))
return true;
}
+
+ if (!mode && !AA->attr().hex())
+ {
+ Latin2Local(msg->by);
+ Latin2Local(msg->to);
+ Latin2Local(msg->re);
+ Latin2Local(msg->txt);
+ }
+
msg->TextToLines(margin);
return true;
}
diff --git a/golded3/geprot.h b/golded3/geprot.h
index b152a8d..51e3464 100644
--- a/golded3/geprot.h
+++ b/golded3/geprot.h
@@ -180,6 +180,7 @@ Line* InsertLine(Line* newline, Line* oldline, int pos);
Line* LastLine(Line* line);
void MakeLineIndex(GMsg* msg, int rmargin, bool getvalue, bool header_recode);
void MsgLineReIndex(GMsg* msg, int viewhidden=-1, int viewkludge=-1, int viewquote=-1);
+void Latin2Local(char *str);
char* XlatStr(char* dest, const char* src, int level, Chs* chrtbl, int qpencoded=false, bool i51=false);
char* mime_header_decode(char* decoded, const char* encoded, char* charset = NULL);
char* strxmimecpy(char* dest, const char* source, int level, int size, bool detect = false);