Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Field header truncated #11

Closed
alexladerman opened this issue Jul 10, 2014 · 6 comments
Closed

Field header truncated #11

alexladerman opened this issue Jul 10, 2014 · 6 comments

Comments

@alexladerman
Copy link

Hi,

Thanks for your tool. Perhaps I am wrong, but I think the field headers should allow up to 10 characters. I try to export with such but I get headers truncated at 8

@tmcw
Copy link
Contributor

tmcw commented Jul 10, 2014

Hm, I'm not sure - 10 is, yes, what it's supposed to be, but it's odd that this wouldn't cause other behavior than just shorter fields.

@alexladerman
Copy link
Author

The file i am trying to generate.... which is used in an old clipper based
accounting program uses 10 character headers.
On Jul 10, 2014 4:36 PM, "Tom MacWright" notifications@github.com wrote:

Hm, I'm not sure - 10 is, yes, what it's supposed to be, but it's odd that this
wouldn't cause other behavior
https://github.com/mapbox/dbf/blob/master/src/structure.js#L48-L50 than
just shorter fields.


Reply to this email directly or view it on GitHub
#11 (comment).

mhkeller added a commit to mhkeller/dbf that referenced this issue Oct 4, 2017
@bakednevada
Copy link

@tmcw the reason it doesn't change behavior is twofold: ArrayBuffers are zero-filled by default and the other operations use the correct offsets, so it's leaving null characters in the trailing bytes of the name. Increasing the number of characters should not have any adverse effects.

@coding-spider
Copy link

Same issue. Any update?

@northtron
Copy link

Hello,
You can override the 8 character limit by changing the f.name.splice(0.8) to (0,10):

field_meta.forEach(function(f, i) { // field name f.name.split('').slice(0, 8).forEach(function(c, x) { view.setInt8(32 + i * 32 + x, c.charCodeAt(0)); }); // field type view.setInt8(32 + i * 32 + 11, f.type.charCodeAt(0)); // field length view.setInt8(32 + i * 32 + 16, f.size); if (f.type == 'N') view.setInt8(32 + i * 32 + 17, 3); });

to

field_meta.forEach(function(f, i) { // field name f.name.split('').slice(0, 10).forEach(function(c, x) { view.setInt8(32 + i * 32 + x, c.charCodeAt(0)); }); // field type view.setInt8(32 + i * 32 + 11, f.type.charCodeAt(0)); // field length view.setInt8(32 + i * 32 + 16, f.size); if (f.type == 'N') view.setInt8(32 + i * 32 + 17, 3); });

@sheindel
Copy link
Contributor

sheindel commented Feb 8, 2023

Happy to report this is finally merged in (#33)! Hopefully we can publish an updated npm package soon

@sheindel sheindel closed this as completed Feb 8, 2023
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

No branches or pull requests

6 participants