home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 22 gnu / 22-gnu.zip / gnurecod.zip / atarist.c < prev    next >
C/C++ Source or Header  |  1994-01-07  |  5KB  |  172 lines

  1. /* Conversion of files between different charsets and usages.
  2.    Copyright (C) 1993, 1994 Free Software Foundation, Inc.
  3.    Francois Pinard <pinard@iro.umontreal.ca>, 1993.
  4.  
  5.    This program is free software; you can redistribute it and/or modify
  6.    it under the terms of the GNU General Public License as published by
  7.    the Free Software Foundation; either version 2, or (at your option)
  8.    any later version.
  9.  
  10.    This program is distributed in the hope that it will be useful, but
  11.    WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with this program; if not, write to the Free Software
  17.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18. */
  19.  
  20. /* Define for using new double step code.  */
  21. #define USE_DOUBLE_STEP 1
  22.  
  23. #include "recode.h"
  24.  
  25. #ifdef USE_DOUBLE_STEP
  26.  
  27. /* RFC 1345 style description for AtariST (non official).  */
  28.  
  29. /* Andreas Schwab writes:
  30.    
  31.    There are some characters which i'm not sure about.  When compared
  32.    with IBM865 (which i think is the original source for the atari
  33.    charset) the characters "bullet operator" and "middle dot" (dec
  34.    249/250) are swapped.  This may be intentional or a bug in the table
  35.    for IBM865.  Also character dec 238 looks more like "element of" than
  36.    "greek small letter epsilon", actually it is a bit too large for both
  37.    interpretations.  I suppose that the other changes were made for
  38.    copyright reasons.  */
  39.  
  40. static DOUBLE_TABLE table =
  41.   {
  42.     "NUSHSXEXETEQAKBLBSHTLFVTFFCRSOSIDLD1D2D3D4NKSYEBCNEMSBECFSGSRSUS",
  43.     "SP! \" NbDO% & ' ( ) * + , - . / 0 1 2 3 4 5 6 7 8 9 : ; < = > ? ",
  44.     "AtA B C D E F G H I J K L M N O P Q R S T U V W X Y Z <(//)>'>_ ",
  45.     "'!a b c d e f g h i j k l m n o p q r s t u v w x y z (!!!!)'?DT",
  46.     "C,u:e'a>a:a!aac,e>e:e!i:i>i!A:AAE'aeAEo>o:o!u>u!y:O:U:CtPdYessFl",
  47.     "a'i'o'u'n?N?-a-o?ININO1214!I<<>>a?o?O/o/oeOEA!A?O?':''/-PICoRgTM",
  48.     "ijIJA+B+G+D+H+W+Z+X+TjJ+K%K+L+M%M+N%N+S+E+P%P+ZjZJQ+R+ShT+SEAN00",
  49.     "a*b*G*p*S*s*m*t*F*H*W*d*Io/0(-(U=3+->==<IuIl-:?2ObSb.MRTnS2S3S'-",
  50.   };
  51.  
  52. #else /* not USE_DOUBLE_STEP */
  53.  
  54. /* Data for Atari ST to ISO Latin-1 code conversions.  */
  55.  
  56. static KNOWN_PAIR known_pairs[] =
  57.   {
  58.     {128, 199},            /* C, */
  59.     {129, 252},            /* u" */
  60.     {130, 233},            /* e' */
  61.     {131, 226},            /* a^ */
  62.     {132, 228},            /* a" */
  63.     {133, 224},            /* a` */
  64.     {134, 229},            /* aa */
  65.     {135, 231},            /* c, */
  66.     {136, 234},            /* e^ */
  67.     {137, 235},            /* e" */
  68.     {138, 232},            /* e` */
  69.     {139, 239},            /* i" */
  70.     {140, 238},            /* i^ */
  71.     {141, 236},            /* i` */
  72.     {142, 196},            /* A" */
  73.     {143, 197},            /* AA */
  74.     {144, 201},            /* E' */
  75.     {145, 230},            /* ae */
  76.     {146, 198},            /* AE */
  77.     {147, 244},            /* o^ */
  78.     {148, 246},            /* o" */
  79.     {149, 242},            /* o` */
  80.     {150, 251},            /* u^ */
  81.     {151, 249},            /* u` */
  82.     {152, 255},            /* y" */
  83.     {153, 214},            /* O" */
  84.     {154, 220},            /* U" */
  85.     {155, 162},            /* \cent */
  86.     {156, 163},            /* \pound */
  87.     {157, 165},            /* \yen */
  88.     {158, 223},            /* \ss */
  89.  
  90.     {160, 225},            /* a' */
  91.     {161, 237},            /* i' */
  92.     {162, 243},            /* o' */
  93.     {163, 250},            /* u' */
  94.     {164, 241},            /* n~ */
  95.     {165, 209},            /* N~ */
  96.     {166, 170},            /* a_ */
  97.     {167, 186},            /* o_ */
  98.     {168, 191},            /* ?' */
  99.  
  100.     {170, 172},            /* \neg */
  101.     {171, 189},            /* 1/2 */
  102.     {172, 188},            /* 1/4 */
  103.     {173, 161},            /* !` */
  104.     {174, 171},            /* `` */
  105.     {175, 187},            /* '' */
  106.     {176, 227},            /* a~ */
  107.     {177, 245},            /* o~ */
  108.     {178, 216},            /* O/ */
  109.     {179, 248},            /* o/ */
  110.  
  111.     {182, 192},            /* A` */
  112.     {183, 195},            /* A~ */
  113.     {184, 213},            /* O~ */
  114.     {185, 168},            /* diaeresis */
  115.     {186, 180},            /* acute accent */
  116.  
  117.     {188, 182},            /* pilcrow sign */
  118.     {189, 169},            /* copyright sign */
  119.     {190, 174},            /* registered trade mark sign */
  120.  
  121.     {221, 167},            /* paragraph sign, section sign */
  122.  
  123.     {230, 181},            /* mu, micro */
  124.  
  125.     {241, 177},            /* +- */
  126.  
  127.     {246, 247},            /* \div */
  128.  
  129.     {248, 176},            /* \deg */
  130.  
  131.     {250, 183},            /* \cdot */
  132.  
  133.     {253, 178},            /* ^2 */
  134.     {254, 179},            /* ^3 */
  135.   };
  136. #define NUMBER_OF_PAIRS (sizeof (known_pairs) / sizeof (KNOWN_PAIR))
  137.  
  138. static void
  139. init_latin1_atarist (STEP *step)
  140. {
  141.   complete_pairs (step, 1, known_pairs, NUMBER_OF_PAIRS, 1);
  142. }
  143.  
  144. static void
  145. init_atarist_latin1 (STEP *step)
  146. {
  147.   complete_pairs (step, 1, known_pairs, NUMBER_OF_PAIRS, 0);
  148. }
  149.  
  150. #endif /* not USE_DOUBLE_STEP */
  151.  
  152. void
  153. module_atarist (void)
  154. {
  155.  
  156. #ifdef USE_DOUBLE_STEP
  157.  
  158.   declare_double_step (&table, "AtariST", 2);
  159.  
  160. #else /* not USE_DOUBLE_STEP */
  161.  
  162.   declare_step ("Latin-1", "AtariST",
  163.         strict_mapping ? ONE_TO_MANY : REVERSIBLE,
  164.         init_latin1_atarist, NULL);
  165.   declare_step ("AtariST", "Latin-1",
  166.         strict_mapping ? ONE_TO_MANY : REVERSIBLE,
  167.         init_atarist_latin1, NULL);
  168.  
  169. #endif /* not USE_DOUBLE_STEP */
  170.  
  171. }
  172.