Skip to content

Conversation

@squeeze69
Copy link

The uint16 can accomodate 65536 records, but dbf has no practical limits beyond maximum file size.
int is guaranteed to be, at least, 32bit.
Added some comment to methods.
Changed FieldName to read up to the first "\x00" , some headers aren't padded with "\x00", so it could return a wrong field name.
This happens with some Clipper compiled programs.

The uint16 can accomodate 65536 records, but dbf has no practical limits beyond maximum file size.
int is guaranteed to be, at least, 32bit.
Added some comment to methods.
Changed FieldName to read up to the first "\x00" , some headers aren't padded with "\x00", so it could return a wrong field name.
This happens with some Clipper compiled programs.
@eentzel
Copy link
Owner

eentzel commented Jan 24, 2017

Changed FieldName to read up to the first "\x00" , some headers aren't padded with "\x00", so it could return a wrong field name.

As far as I can tell, the existing TrimRight was doing exactly this. Do you have a unit test that fails without this change and passes with it?

@squeeze69
Copy link
Author

Hi, strings.TrimRight removes all the trailing specified cutset runes.

I didn't build a unit test (yet), but I do have a bunch of Clipper's generated dbf with this non standard format. I've met this problem before. Clipper (maybe, only some versions) doesn't pad the name field with 0x00. I suppose they didn't care, after all, if you're using a strcpy (from C) function, the padding is only a waste of time.

The fields' names are something like:
NAME\x00(pieces from previous field names, if longer).\x00

LibreOffice does import any of these slightly malformed dbf.

See the sample attached.
testdbf_clipper_generated.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants