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

support for CP1252 encoding #6

Open
SamDecrock opened this issue Apr 6, 2014 · 1 comment
Open

support for CP1252 encoding #6

SamDecrock opened this issue Apr 6, 2014 · 1 comment

Comments

@SamDecrock
Copy link

according to what I read on the internet, DBF doesn't use UTF-8 encoding (for characters like è, é, ü, and so on...), but the Windows CP1252 encoding.

Could you fix that so it supports CP1252 decoding?

Thx!

@sin-raben
Copy link

sin-raben commented Jul 14, 2016

in /lib/parser

 Parser.prototype.parseField = function(field, buffer) {
      var value;
      if ((field.type === 'C')&&(this.encodingFunction)) {
          value = (this.encodingFunction(buffer)).trim();
      } else {
          value = (buffer.toString(this.encoding)).trim();
      }
      if (field.type === 'N') {
        value = parseInt(value, 10);
      } else if (field.type === 'F') {
        value = value === +value && value === (value | 0) ? parseInt(value, 10) : parseFloat(value, 10);
      }
      return value;
    };

in project

var iconv = require('iconv-lite');
....
parser.encodingFunction = function (buffer) {
    return iconv.decode(new Buffer(buffer), 'CP866'); //CP1252....
};

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

2 participants