% kb2lex.tex                               An idea of Bernard Gaulle 07/19/92
%                                                            V1.3 of 03/08/95
%                           Copyright GUTenberg-Bernard Gaulle as in french.doc
%
% Running this code will produce two files: kbtex7a8.lex and kbtex8a7.lex
% These files are the result of the understanding of keyboard.dat in which
% the user has specified the special 8-bit characters he is using via
% his own keyboard. A document typed in with this encoding can't be send
% to anyone else except people having exactly the same keyboard.
% kb2lex is a way to produce programs that will allow to translate .tex
% files from 8-bit to single 7-bit ASCII standard that everyone normally
% is able to use.
%
% Of course you need the Unix pgm lex to generate the appropriate pgms.
% But if you don't have it, I've given in this directory kbtex7a8.c and
% kb8a7.c that were produced on my machine with the default keyboard.dat.
%
%  1- Configurate your keyboard.dat to your own needs.
%  2- TeX or LaTeX this file (with any TeX V3.14xxx motor)
%     if not OK go back to 1- for corrections (notice that it must run
%                                            with the distributed keyboard.dat)
%     All processed characters are displayed to your screen (and in the .log 
%     file). Check if no character is displayed in TeX hexadecimal format 
%     (^^xx). In which case, you must be aware that these will never be 
%     converted to 7-bit. Since you can't display it as usual on your screen
%     and probably you can't also input it asis, you should  chose to delete
%     them from  keyboard.dat. Do it and rerun this step.
%  3- Type in: 
%              (as i type in Unix but may need to be adapted...)
%              lex -v kb8to7.lex;cc -o kb8to7 lex.yy.c -ll
%         and: lex -v kb7to8.lex;cc -o kb7to8 lex.yy.c -ll;rm lex.yy.c
%     (if any pb on your platform try flex instead of lex)
%  4- Test kb7to8 and kb8to7 to your modified kbto.tex file:
%              kb7to8 <kbto.tex
%              kb8to7 <kbto.tex
%  5- Copy the pgms kb8to7 and kb7to8 
%     in a public (/local/bin) directory so they will be available for 
%     everybody.
%
%%
%%      checksum        = "32173 79 479 3878"
%%
\global\newlinechar`\^^J%
\newif\ifLEX\LEXtrue
\let\ifLEXhic\iftrue% for any debugging
\newwrite\kbseven\immediate\openout\kbseven=kb8to7.lex
\newwrite\kbeight\immediate\openout\kbeight=kb7to8.lex
\message{^^J Writing kb8to7.lex and kb7to8.lex}
{\catcode`\%=11
\immediate\write\kbseven{%% /* kb8to7.lex converts my 8-bit TeX documents 
                               to a standard 7-bit ASCII */}
\immediate\write\kbeight{%% /* kb7to8.lex converts std 7-bit ASCII TeX
                               documents to my prefered 8-bit */} 
}
\let\protect\empty% nothing need to be protect in the output
                             \def\tempfmt{lplain}%
                             \ifx\fmtname\tempfmt\else\def\tempfmt{LaTeX2e}\fi%
                             \ifx\fmtname\tempfmt%
\ifx\documentclass\undefined
\documentstyle[titlepage]{article}
\else
\documentclass[titlepage]{article}
%\usepackage[T1]{fontenc}% l'encodage ne devrait rien changer
%\usepackage{keyboard}% see below
\fi
\nofiles
\begin{document} 
                                                          \fi
\catcode`@=11% if coming from plain
\input keyboard.sty % load it directly  with TeX 
\gdef\folio{}%
\message{(CHECK the list for hexadecimal TeX codes you can't  display and
          must be eliminated from keyboard.dat)}
                                        \ifx\fmtname\tempfmt\def\tempa
{\end{document}}% LaTeX end
                                        \else\def\tempa{\csname bye\endcsname}
                                        \fi\tempa%
\endinput%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
