Subject: Converting tab into spaces (Unix Pine 394)?

From: [email-masked] (Jie Yuan)
Date: 18 Jun 1996 16:45:04 GMT

Sometimes, tabs in my email get screwed up in the recipients end.
I had to convert tabs into spaces manually.  I thought Pine can do
it on the fly, but I don't know how to get Pine do it.  Any help
will be greatly appreciated!

Jie
-- Jie Yuan, PhD - U. Cincinnati - Pharmacology & C.B. --
== POBox 670575, Cin., OH 45267-0575  =  513-558-2352  ==
== [email-masked] = www.uc.edu/~yuanj =  using Knews  ==
== finger -l [email-masked] for my PGP pub. key=

---

From: Vladimír Solnický {Vladimir Solnicky} <[email-masked]>
Date: Wed, 19 Jun 1996 18:09:41 +0200 (METDST)

> will be greatly appreciated!

A stupid solution that replaces every tab character by fixed number of
spaces:

Install the following line as your sending filter (pine 3.92 or newer
required) and set the feature which defaults to automatic use of the first
filter on sending the mail (replace `@' by <tab> charcater and `****' by
appropritate number of spaces).

sed -e 's/@/****/g'

`Smarter' solution counting th eactual column requires more programming.

Regards, V. S.

Vladimír Solnický, ÚTIA AV ČR, Pod vodárenskou věží 4,
182 08 Praha 8-Libeň, +42 2 6605/2364, telefax: +42 2 6884677,
[email-masked], http://www.utia.cas.cz/user_data/vs/vs-home-cz.html

---

From: Richard Gering <[email-masked]>
Date: Thu, 20 Jun 1996 22:02:33 +0100 (WET)

On Wed, 19 Jun 1996, [ISO-8859-2] Vladimír Solnický {Vladimir Solnicky} wrote:

> Vladimír Solnický, ÚTIA AV ÈR, Pod vodárenskou vì¾í 4,
> 182 08 Praha 8-Libeò, +42 2 6605/2364, telefax: +42 2 6884677,

I hope I'm not getting too far off topic with this one, but I've included
a little script I had to write last year to converts TABs into spaces
while keeping the columns into consideration. Just hand it the original
tab-stop as an argument ("tab2spc 8").

The program only works well on clean text-only ASCII files.

Regards,

- Richard Gering.

+-----------------------------------------------------------------------------+
| Richard Gering ([email-masked]) | Let me make one thing perfectly clear:  |
| CI International B.V. Netherlands | I never explain anything! (Mary Poppins)| 
+-----------------------------------------------------------------------------+
:
################################################################################
# Program    :  tab2spc
#
# Start      :  02/20/95  Richard Gering
#
# Description:  A small program to convert all TABs on stdin to spaces,
#               using the (original) tab-stop provided by the user.
#
# Limitations:  In its current implementation, every TAB position is considered
#               to be a multiple of the given tab-stop.
#                
# GNU Licensed
#
################################################################################
prg=`basename $0`
tab_stop=$1
if [ $# -ne 1 ]
then
	echo "USAGE: $prg <original tab-stop>" >&2
	echo "       Convert all TABs on stdin to spaces, using the given tab-stop." >&2
	exit 1
fi

awk -v tab_stop=$tab_stop '
BEGIN {
	tabsubst="";
	for (x = 1; x <= tab_stop; x++)
		tabsubst=" " tabsubst;
}
{
	line_in=$0;
	while (tab_pos = index(line_in, "\t")) 
	{
		add_spc=tab_stop - ((tab_pos - 1) % tab_stop);
		sub("\t", substr(tabsubst, 1, add_spc), line_in);
	}
	printf("%s\n", line_in);
}
'

exit 0

---

From: Ravi Krishna <[email-masked]>
Date: Fri, 21 Jun 1996 13:48:04 -0500 (GMT)

> > > I had to convert tabs into spaces manually.  I thought Pine can do
...
> > A stupid solution that replaces every tab character by fixed number of
...
> > `Smarter' solution counting th eactual column requires more programming.
...
> tab-stop as an argument ("tab2spc 8").
...

Try one of the Unix commands `expand' or `newform', whichever is
available on your system.

--  Ravi Krishna <[email-masked]>, Fri Jun 21 13:49:24 IST 1996

---

From: [email-masked] (Orjan Johansen)
Date: 20 Jun 1996 03:53:05 GMT

In article <[email-masked]>,
>`Smarter' solution counting th eactual column requires more programming.

There may already be a command "expand" in your system which does this
smarter counting. I use to pipe through that whenever I have used <tab>s
in a message.

Greetings,
Ørjan.

---

From: "Mihai T. LAZARESCU" <[email-masked]>
Date: Fri, 21 Jun 1996 22:12:22 +0100

> The program only works well on clean text-only ASCII files.

While you are on UNIX, why don't you use the `expand' command?

NAME
     expand - convert tabs to spaces

SYNOPSIS
     expand  [-tab1[,tab2[,...]]]  [-t  tab1[,tab2[,...]]]   [-i]
     [--tabs=tab1[,tab2[,...]]]  [--initial] [--help] [--version]
     [file...]

Mihai L.
--
Mihai Teodor LAZARESCU               Ph.D. student
  Voice: + 39 (0)11 564 5128      |  Polytechnic of Turin
  Fax  : + 39 (0)11 564 4134      |  Electronics & Communic. Department
  email: [email-masked]      |  Corso Duca degli Abruzzi, 24
  http://ccmserv.polito.it/mihai/ |  10129 TORINO, ITALY

---

From: Richard Gering <[email-masked]>
Date: Mon, 24 Jun 1996 16:21:13 +0100 (WET)

> While you are on UNIX, why don't you use the `expand' command?

Thanks for the advise. The command 'expand' does not exist on my SCO Unix
3.2v4.2 system (it was first introduced in 3.2v5.0, a.k.a. OpenServer 5),
but my version does support the command 'newform´, which can also be used
to do the job (thanks to Ravi Krishna for pointing this out). 

I've been working heavily with Unix for some 10 years and never ran across
either command. Simply never required it. When a co-worker needed a tool
to convert tabs to spaces in a hurry I slapped together the forementioned
script. Glad to know there is a real solution to the problem. Unix can
do almost anything, as long as you're asking the right questions :-)

We now quickly return you to your regular program...

Regards,

- Richard.