/* Nserver For Linux Copyright (C) 1999 Sean Billings This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ /*routines to assist in mapping 8-bit GEOS/DOS Codepage 437 characters to unix*/ unsigned char tounix[128]; void swap_charmap(unsigned int s1,unsigned int s2){ /*swap s1 and s2 in the tounix array*/ unsigned char tmp; s1-=128; s2-=128; tmp=tounix[s1]; tounix[s1]=tounix[s2]; tounix[s2]=tmp; } void init_charmap(void){ /*run once to initialise the tounix array*/ unsigned int a,b; unsigned int found; /*fill array with GEOS map first*/ for(a=0;a<128;a++) tounix[a]=a+128; /*now modify the map*/ swap_charmap(132,228); swap_charmap(148,246); swap_charmap(129,252); swap_charmap(225,223); swap_charmap(142,196); swap_charmap(153,214); swap_charmap(154,220); swap_charmap(128,199); swap_charmap(165,209); swap_charmap(135,231); } void geos2unix(unsigned char *txt){ unsigned int a; for(a=0;a127) txt[a]=tounix[txt[a]-128]; } } void unix2geos(unsigned char *txt){ unsigned int a,b; for(a=0;a127){ for(b=0;b<128;b++){ if(tounix[b]==txt[a]){ txt[a]=b+128; break; } } } } } /* void main(void){ unsigned char text[257]; unsigned int a; strcpy(text,"aoub"); text[0]=132; text[1]=148; text[2]=129; text[3]=225; init_charmap(); printf("before: %d %s\n",strlen(text),text); geos2unix(text); printf("after: %d %s\n",strlen(text),text); unix2geos(text); printf("after2: %s\n",text); for(a=0;a