[comp.sys.mac.programmer] Representing MPW special chars on the net

ldo@waikato.ac.nz (Lawrence D'Oliveiro, Waikato University) (10/17/90)

There's occasionally a need to post bits of MPW Shell scripts, Makefiles
etc to this newsgroup. The trouble, as you know, is MPW's use of Mac-
specific special characters, which are somewhat hard to represent
in standard 7-bit ASCII.

You could always BinHex the offending files, but this is somewhat
inconvenient for a 3- or 4-line example that you would like to include
in a semi-readable form, directly with the explanatory text that goes
with it.

What we need, in other words, is an escape convention for representing
these special characters using just 7-bit ASCII.

I propose that we use the character that the same key produces (on
US keyboards) without the option modifier, and write this prefixed by
an escape character.

I further propose that we use the backslash ("\") as the escape
character, as this bears the closest resemblance to the graphic
that seems to be Apple's standard for representing the option
modifier key. If you want to see what Apple's graphic looks like,
try defining an option-key shortcut in MacroMaker.

Here are a few equivalences, to give you the idea:

	\8	bullet (option-8)
	\d	lowercase delta (option-d)
	\f	"function of" symbol (option-f)
	\/	division symbol (option-slash)
	\+	plus/minus symbol (option-plus, ie option-shift-equals)

As an example, here's what a Link command might look like in a
Makefile:

	MyApp \f\f "{Objs}"MyApp.mod.o
	    Link -o MyApp -t APPL -c MYAP \d
		"{Objs}"MyApp.mod.o \d
		"{MLibraries}"MInterface.o \d
		"{MLibraries}"MRuntime.o \d
		"{Libraries}"Interface.o \d
		"{Libraries}"Runtime.o

To make things easier, I've written a couple of MPW tools (using
Metrowerks Modula-2) to do the conversion automatically. I'll
reproduce here the part of the code that sets up the translation
tables--feel free to suggest any improvements, spot any mistakes
or omissions, whatever.

First, a couple of notes:

I've defined the table to include every special character
that I thought might be useful, whether MPW actually has a
use for it at present or not. This means I've included practically
everything in the Monaco character set except for the accented
vowels.

There are a couple of exceptions to the rule for forming the
7-bit ASCII equivalent for the special character: the international
opening quote (looks like "<<") is generated with option-backslash,
and I wanted to keep the sequence "\\" for representing the
backslash character itself! So I thought I'd use the sequence
"\`" for this, since option-` is a "dead key" which doesn't itself
stand for any special character.

Finally, here's the list of table entries, expressed as a sequence
of calls to a routine which builds the table. The decimal number
is the Mac character code for the special character, while the
character in quotes is its 7-bit ASCII representation (without
the escape prefix).

	AddEntry(160, 't');	(* up-arrow *)
	AddEntry(161, '*');	(* degree symbol *)
	AddEntry(162, '4');	(* cents symbol *)
	AddEntry(163, '3');	(* pound symbol *)
	AddEntry(164, '6');	(* section symbol *)
	AddEntry(165, '8');	(* bullet symbol *)
	AddEntry(166, '7');	(* paragraph symbol *)
	AddEntry(167, 's');	(* German double-s *)
	AddEntry(168, 'r');	(* registered trademark *)
	AddEntry(169, 'g');	(* copyright symbol *)
	AddEntry(170, '2');	(* trademark symbol *)
	AddEntry(173, '=');	(* not-equals *)
	AddEntry(176, '5');	(* infinity *)
	AddEntry(177, '+');	(* plus/minus *)
	AddEntry(178, ',');	(* less than or equal *)
	AddEntry(179, '.');	(* greater than or equal *)
	AddEntry(180, 'y');	(* yen sign *)
	AddEntry(181, 'm');	(* mu *)
	AddEntry(182, 'd');	(* lowercase delta *)
	AddEntry(183, 'w');	(* uppercase sigma *)
	AddEntry(184, 'P');	(* uppercase pi *)
	AddEntry(185, 'p');	(* lowercase pi *)
	AddEntry(186, 'b');	(* integral sign *)
	AddEntry(187, '9');	(* feminine ordinal *)
	AddEntry(188, '0');	(* masculine ordinal *)
	AddEntry(189, 'z');	(* uppercase omega *)
	AddEntry(192, '?');	(* inverted question mark *)
	AddEntry(193, '1');	(* inverted exclamation mark *)
	AddEntry(194, 'l');	(* logical negation symbol *)
	AddEntry(195, 'v');	(* square-root symbol *)
	AddEntry(196, 'f');	(* function symbol *)
	AddEntry(197, 'x');	(* approximately equal to *)
	AddEntry(198, 'j');	(* uppercase delta *)
	AddEntry(199, '`'); (* international opening quote (special code) *)
	AddEntry(200, '|');	(* international closing quote *)
	AddEntry(201, ';');	(* ellipsis *)
	AddEntry(202, ' ');	(* hard space *)
	AddEntry(214, '/');	(* division symbol *)
	AddEntry(215, 'V');	(* diamond symbol *)
	AddEntry(217, '~');	(* identity symbol *)

Once we get this finalized, I'll be happy to post the translation
tools, including complete source code.

Lawrence D'Oliveiro                       fone: +64-71-562-889
Computer Services Dept                     fax: +64-71-384-066
University of Waikato            electric mail: ldo@waikato.ac.nz
Hamilton, New Zealand    37^ 47' 26" S, 175^ 19' 7" E, GMT+12:00
This line intentionally left incom