How to use the iconv-lite.encodings function in iconv-lite

To help you get started, we’ve selected a few iconv-lite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github petermikitsh / myethereumapp / src / server / __tests__ / __setup__.js View on Github external
import iconv from 'iconv-lite';
import encodings from 'iconv-lite/encodings';
import enzyme from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';

// For info on this hack:
// https://stackoverflow.com/questions/46227783/encoding-not-recognized-in-jest-js
iconv.encodings = encodings;

enzyme.configure({ adapter: new Adapter() });
github sozialhelden / accessibility-cloud / both / api / sources / server / stream-chain / stream-types / convert-to-utf8.js View on Github external
import iconv from 'iconv-lite';
import { check } from 'meteor/check';

iconv.encode('', 'utf8'); // Load all encodings -- iconv-lite has no real interface for this yet.
if (!iconv.encodings) {
  // If this should be thrown, you have to update the code to fetch the available iconv
  // encoding names in a new way.
  check(iconv.encodings, [String]);
  throw new Error('No iconv encodings available. Please update implementation.');
}

export default class ConvertToUTF8 {
  constructor({ fromCharSet = 'utf8' }) {
    check(fromCharSet, String);
    this.stream = iconv.decodeStream(fromCharSet);
  }

  dispose() {
    delete this.stream;
  }
github sozialhelden / accessibility-cloud / both / api / sources / server / stream-chain / stream-types / convert-to-utf8.js View on Github external
import iconv from 'iconv-lite';
import { check } from 'meteor/check';

iconv.encode('', 'utf8'); // Load all encodings -- iconv-lite has no real interface for this yet.
if (!iconv.encodings) {
  // If this should be thrown, you have to update the code to fetch the available iconv
  // encoding names in a new way.
  check(iconv.encodings, [String]);
  throw new Error('No iconv encodings available. Please update implementation.');
}

export default class ConvertToUTF8 {
  constructor({ fromCharSet = 'utf8' }) {
    check(fromCharSet, String);
    this.stream = iconv.decodeStream(fromCharSet);
  }

  dispose() {
    delete this.stream;
  }

  static getParameterSchema() {
    return {
      fromCharset: {
github sozialhelden / accessibility-cloud / both / api / sources / server / stream-chain / stream-types / convert-to-utf8.js View on Github external
static getParameterSchema() {
    return {
      fromCharset: {
        type: String,
        allowedValues: iconv.encodings,
      },
    };
  }
}
github NielsLeenheer / EscPosEncoder / src / esc-pos-encoder.js View on Github external
'windows1254': [0x5b, false],
            'windows1255': [0x20, false],
            'windows1256': [0x5c, false],
            'windows1257': [0x19, false],
            'windows1258': [0x5e, false],
        };

        let codepage;

        if (!iconv.encodingExists(value)) {
            throw new Error('Unknown codepage');
        }

        if (value in iconv.encodings) {
            if (typeof iconv.encodings[value] === 'string') {
                codepage = iconv.encodings[value];
            } else {
                codepage = value;
            }
        } else {
            throw new Error('Unknown codepage');
        }

        if (typeof codepages[codepage] !== 'undefined') {
            this._codepage = codepage;
            this._state.hanzi = codepages[codepage][1];

            this._queue([
                0x1b, 0x74, codepages[codepage][0],
            ]);
        } else {
            throw new Error('Codepage not supported by printer');
github NielsLeenheer / EscPosEncoder / src / esc-pos-encoder.js View on Github external
'windows1252': [0x47, false],
            'windows1253': [0x5a, false],
            'windows1254': [0x5b, false],
            'windows1255': [0x20, false],
            'windows1256': [0x5c, false],
            'windows1257': [0x19, false],
            'windows1258': [0x5e, false],
        };

        let codepage;

        if (!iconv.encodingExists(value)) {
            throw new Error('Unknown codepage');
        }

        if (value in iconv.encodings) {
            if (typeof iconv.encodings[value] === 'string') {
                codepage = iconv.encodings[value];
            } else {
                codepage = value;
            }
        } else {
            throw new Error('Unknown codepage');
        }

        if (typeof codepages[codepage] !== 'undefined') {
            this._codepage = codepage;
            this._state.hanzi = codepages[codepage][1];

            this._queue([
                0x1b, 0x74, codepages[codepage][0],
            ]);