[GreenKeys] ASCII <-> Baudot algorithm
Brent Jones
gijones at clear.net.nz
Sun Aug 2 00:36:18 EDT 2015
Hi
I haven't checked the BASIC on the C64 but I have used this type of
algorithm both in BASIC and C to convert ASCII to
Baudot. ( An aside although it is called Baudot most of the character
set arrangement we use was done by a
New Zealander called Donald Murray ).
1) set up an array of characters that contains the all the characters in
the Baudot Character in numeric sequence.
E.g BaudotString = "E*A SIU*DRJNFCKTZLWHYPQOBG*MXV*3*-
'87**4*,%:(5+)2$6019?@*.=/"
I use the principle of the array starting at one you may need to allow
for this by putting a non printing character
marker in position 0 depending on Commodore BASIC.
I put the codes for those characters printed when in Letter Shift e.g
letters in the 1 to 31 range.
I then put those characters printed when in Figure shift mode starting
at 32.
Where the you see * that is as a place holder for non printing
characters to keep the number values in correct order.
Also note depending on the machine you will be using some of the
characters made need changing.
On the Creed teleprinters I use we have a + sign as the FIG character
for the Z key but other machines they may have "
So to send take a character from the ASCII message you want to send,
make sure it is in Upper Case as it makes things
easier. Then either using a built-in string function or one you have
written your self search BaudotString for the character
you have in ASCII and get the number for it's position number. This is
it's Baudot value, note if the character is in the FIG section
it's Baudot value will be + 31.
Also allow a method of returning a value if the the character you want
is not found in the Baudot string.
If this occurs I tend to set it for the value of the question mark + the
31 shift value.
Then with a series of If statements you decide if you need to shift into
Figures or Letter mode before printing
the actual character value.
I.e if my search for 3 returns 32 then I know I will need to send a Figs
shift before I need to send 32 - 31 = 1 as 32 > 31 .
By using flags in your code you can keep track of whether you are in
Letters or Figures mode.
Remember these values need to be sent as the binary values not decimal
values e.g V ( 30) must be sent as binary 11110 or hex 1E not as two
characters
one character of 3 then 0 . My apologies if I made this bit too simple.
I have only talked about ASCII to Baudot conversion but Baudot to ASCII
basically follows in reverse.
I hope this may be of help to someone.
Brent Jones
More information about the GreenKeys
mailing list