1
votes

How to check the bytes for dbf file type in hex viewer to retrieve the dbf version?

Example screenshot below was taken from a FoxBASE+/Dbase III plus, no memo

Based on the article from http://www.digitalpreservation.gov/formats/fdd/fdd000325.shtml.

0x03 = FoxBASE+/Dbase III plus, no memo

Can I understand that the first line first character 03 = 0x03?

03 75 02 11 92 00 00

Foxbase /DBaseIII Plus, no memo

Below is the unknown DBase version that I would like to check. It starts with 04 75 02 10 DF How can I know which version of dBase is this?

I tried to connect using php dbase_open however it doesn't work. (error msg: 'Warning: dbase_open(): unable to open database C:...')

Unknown Dbase version

1

1 Answers

2
votes

I think I have found the anwser, http://www.dbase.com/KnowledgeBase/int/db7_file_fmt.htm

04 = 4 for dBASE Level 7.

The header structure is exactly the same as describe in dbase website.

Byte    Contents      Description
0       1 byte        Valid dBASE for Windows table file, bits 0-2 indicate version number: 3 for dBASE Level 5, 4 for dBASE Level 7. Bit 3 and bit 7 indicate presence of a dBASE IV or dBASE for Windows memo file; bits 4-6 indicate the presence of a dBASE IV SQL table; bit 7 indicates the presence of any .DBT memo file (either a dBASE III PLUS type or a dBASE IV or dBASE for Windows memo file).
1-3     3 bytes       Date of last update; in YYMMDD format.  Each byte contains the number as a binary.  YY is added to a base of 1900 decimal to determine the actual year. Therefore, YY has possible values from 0x00-0xFF, which allows for a range from 1900-2155.
4-7     32-bit        Number of records in the table. (Least significant byte first.)
8-9     16-bit        Number of bytes in the header. (Least significant byte first.)
10-11   16-bit        Number of bytes in the record. (Least significant byte first.)
12-13   2 bytes       Reserved; filled with zeros.
14      1 byte        Flag indicating incomplete dBASE IV transaction.
15      1 byte        dBASE IV encryption flag.
16-27   12 bytes      Reserved for multi-user processing.
28      1 byte        Production MDX flag; 0x01 if a production .MDX file exists for this table; 0x00 if no .MDX file exists.
29      1 byte        Language driver ID.
30-31   2 bytes       Reserved; filled with zeros.
32-63   32 bytes      Language driver name.
64-67   4 bytes       Reserved.
68-n    48 bytes each   Field Descriptor Array (see 1.2).
n+1     1 byte        0x0D stored as the Field Descriptor terminator.
n+2                   Field Properties Structure

1.2 Field Descriptor Array

(One for each field in the table) 
Byte    Contents    Description
0-31    32 bytes    Field name in ASCII (zero-filled).
32      1 byte      Field type in ASCII (B, C, D, N, L, M, @, I, +, F, 0 or G).
33      1 byte      Field length in binary.
34      1 byte      Field decimal count in binary.
35-36   2 bytes     Reserved.
37      1 byte      Production .MDX field flag; 0x01 if field has an index tag in the production .MDX file; 0x00 if the field is not indexed.
38-39   2 bytes     Reserved.
40-43   4 bytes     Next Autoincrement value, if the Field type is Autoincrement, 0x00 otherwise.
44-47   4 bytes     Reserved.

Example

;04 = 4 for dBASE Level 7
;75 02 10 = Date of last update; in YYMMDD
;DF = 223 number of record

; 0  1  2  3  4  5  6  7   8  9 10 11 12 13 14 15

 04 75 02 10 DF 00 00 00  15 03 B6 00 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 44 42 57 49 4E 55 53 30  00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00

;Column name start from 68 offset (Need to convert from hex to ascii)
;http://www.rapidtables.com/convert/number/hex-to-ascii.htm
;Example, 53 49 54 45  4E 4D = SITENM

;64 65 66 67 68 69 70 71  72 73 74 75 76 77 78 79
;            00 01 02 03 04  05 06 07 08 09 10 11  

 00 00 00 00 53 49 54 45  4E 4D 00 00 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00

;(See 1.2 Field Descriptor Array) 
;0-31 = Field name in ASCII (zero-filled)
;32   = Field type in ASCII 
;From below example the field type is 43 which is equal to 'C' in ascii
;33   = Field length in binary.
;From below example the field length is 0A which is equal to '10' in decimal
;28 29 30 31 32 33 34 35  36 37 38 39 40 41 42 43

 00 00 00 00 43 0A 00 00  00 00 00 00 00 00 00 00

;Column will start from 00 and end in offset 47 (total 48 bytes until it readched '0D' Field Descriptor terminator)
;So below 00 is start with another column 
;Example, 44 41 54 45 = DATE  

;44 45 46 47 00 01 02 03 04  05 06 07 08 09 10 11

 00 00 00 00 44 41 54 45  00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 0A 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 54 49 4D 45  00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 08 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 54 52 41 4E  53 5F 43 4F 44 45 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 02 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 54 52 41 4E  53 5F 44 45 53 43 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 1E 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 42 55 53 4E  4F 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 02 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 55 4E 49 54  4E 4F 00 00 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 02 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 52 45 41 44  45 52 4E 4F 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 02 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 4F 4E 54  4E 41 4D 45 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 0C 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 44 52 4E 41  4D 45 00 00 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 0C 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 41 52 44  4E 4F 00 00 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 06 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 4E 41 4D 45  00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 23 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 44 45 50 54  00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 0C 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 4A 4F 42 00  00 00 00 00 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 0C 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 49 46 49 45  4C 44 00 00 00 00 00 00
 00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 43 1A 00 00  00 00 00 00 00 00 00 00
 00 00 00 00 0D -> Here is the Field Descriptor terminator '0D'
```