From 32f4817a791e1680af2edd6e6f3bb4b7ce1c3ece Mon Sep 17 00:00:00 2001
From: rswindell <>
Date: Wed, 30 Oct 2002 02:40:16 +0000
Subject: [PATCH] Extended-ASCII chars are only convert to ASCII during export
 if the SUB_ASCII toggle is set. Extended-ASCII chars in the message Subject
 are now converted as well. Extended-ASCII chars can now be converted during
 import by using the 'a' (ASCII only) area flag in the newslink.cfg file.

---
 exec/newslink.js | 28 +++++++++++++++++++++++-----
 1 file changed, 23 insertions(+), 5 deletions(-)

diff --git a/exec/newslink.js b/exec/newslink.js
index 4b949687ab..e7cc488fbf 100644
--- a/exec/newslink.js
+++ b/exec/newslink.js
@@ -11,9 +11,15 @@
 // port		TCP port number (defaults to 119)
 // user		username (optional)
 // pass		password (optional)
-// area		subboard (internal code) newsgroup
+// area		subboard (internal code) newsgroup flags
 // ...
 
+// Defined area flags:
+// x		do not add tearlines & taglines to exported messages
+// n		do not add "From Newsgroup" text to imported messages
+// t		do not add tearline to imported messages
+// a		convert extended-ASCII chars to ASCII on imported messages
+
 const REVISION = "$Revision$".split(' ')[1];
 
 printf("Synchronet NewsLink %s session started\r\n", REVISION);
@@ -263,18 +269,25 @@ for(i in area) {
 		if(hdr.from_net_type==NET_INTERNET)	/* no dupe loop */
 			continue;
 		if(hdr.from_net_type	/* don't gate messages between net types */
-			&& msgbase.settings!=null && !(msgbase.settings&SUB_GATE))
+			&& msgbase.settings!=undefined && !(msgbase.settings&SUB_GATE))
 			continue;
 
-		body = msgbase.get_msg_body(false, ptr
+		body = msgbase.get_msg_body(
+				 false	/* retrieve by offset */
+				,ptr	/* message number */
 				,true	/* remove ctrl-a codes */
 				,true	/* rfc822 formatted text */
-				,true	/* include tails */);
+				,true	/* include tails */
+				);
 		if(body == null) {
 			printf("!FAILED to read message number %ld\r\n",ptr);
 			continue;
 		}
-		body = ascii_str(body);
+		if(msgbase.settings!=undefined && msgbase.settings&SUB_ASCII) {
+			/* Convert Ex-ASCII chars to approximate ASCII equivalents */
+			body = ascii_str(body);
+			hdr.subject = ascii_str(hdr.subject);
+		}
 		if(flags.indexOf('x')==-1) {
 			body += tearline;
 			body += tagline;
@@ -529,6 +542,11 @@ for(i in area) {
 			continue;
 		}
 
+		if(flags.indexOf('a')>=0) {	// import ASCII only (convert ex-ASCII to ASCII)
+			body = ascii_str(body);
+			hdr.subject = ascii_str(hdr.subject);
+		}
+
 		hdr.from_net_type=NET_INTERNET;
 //		hdr.from_net_addr=hdr.from;
 		if(flags.indexOf('t')==-1)
-- 
GitLab