1 /**********************************************************************
2  *	CODEPAGES.H
3  * 	Header file with codepage definitions for dbf
4  *  using ISO-8559-1 definitions (Latin 1) to encode
5  *  Author: Bjoern Berg, September 2002
6  *  Email: clergyman@gmx.de
7  *  dbf Reader and converter for dBase
8  *  Version 0.3
9  *
10  *  History:
11  *  - Post 0.6
12  *	  unified cp850 and ascii conversions to speed things up
13  *  - Version 0.3 - 2003-04-20
14  *	  splitted to codepages.h and codepages.c
15  *  - Version 0.2 - 2003-01-30
16  *	  included patch by Christian Vogel:
17  *	  changes all occurences of "char" to "unsigned char"
18  *    This avoids many warnings about "case statement out of range"
19  *  - Version 0.1 - 14.09.2002
20  *	  first implementation, using iso-definitions
21  ********************************************************************/
22 
23 #include "codepages.h"
24 
25 static const unsigned char CP850andASCIItable[] = {
26 	/*        	0/8	1/9	2/A	3/B	4/C	5/D	6/E	7/F	*/
27 	/* 0x80: */	0x0,	0xFC,	0xE9,	0xE2,	0xE4,	0xE9,	0x0,	0x0,
28 	/* 0x88: */	0xEA,	0x0,	0xE8,	0x0,	0xEE,	0xEC,	0xC4,	0x0,
29 	/* 0x90: */	0xC9,	0x0,	0x0,	0xF4,	0xF6,	0xF2,	0xFB,	0xF9,
30 	/* 0x98: */	0x0,	0xD6,	0xDC,	0x0,	0x0,	0x0,	0x0,	0x0,
31 	/* 0xA0: */	0xE1,	0xED,	0xF3,	0xFA,	0x0,	0x0,	0x0,	0x0,
32 	/* 0xA8: */	0x0,	0x0,	0x0,	0x0,	0x0,	0x0,	0x0,	0x0,
33 	/* 0xB0: */	0x0,	0x0,	0x0,	0x0,	0x0,	0xC1,	0xC2,	0xC0,
34 	/* 0xB8: */	0x0,	0x0,	0x0,	0x0,	0x0,	0x0,	0x0,	0x0,
35 	/* 0xC0: */	0x0,	0xC1,	0xC2,	0x0,	0xC4,	0x0,	0x0,	0x0,
36 	/* 0xC8: */	0xC8,	0xC9,	0xCA,	0x0,	0xCC,	0xCD,	0xCE,	0x0,
37 	/* 0xD0: */	0x0,	0x0,	0xCA,	0xDA,	0xD4,	0x0,	0xCD,	0xCE,
38 	/* 0xD8: */	0x0,	0xD9,	0xDA,	0xDB,	0xDC,	0x0,	0xCC,	0xDF,
39 	/* 0xE0: */	0xE9,	0xDF,	0xD4,	0xD2,	0xE4,	0x0,	0x0,	0x0,
40 	/* 0xE8: */	0xE8,	0xD3,	0xDB,	0xD9,	0xEC,	0xED,	0xEE,	0x0,
41 	/* 0xF0: */	0x0,	0x0,	0xF2,	0xF3,	0xF4,	0x0,	0xF6,	0x0,
42 	/* 0xF8: */	0x0,	0xF9,	0xFA,	0xFB,	0xFC,	0x0
43 };
44 
45 void
cp850andASCIIconvert(unsigned char * src)46 cp850andASCIIconvert(unsigned char *src)
47 {
48 	int index;
49 	for (; *src; src++) {
50 		index = *src - 0x80;
51 		if ((index >= 0 || index < sizeof(CP850andASCIItable))
52 		    && CP850andASCIItable[index])
53 			*src = CP850andASCIItable[index];
54 	}
55 }
56