How to use the iconv-lite.extendNodeEncodings 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 jedmao / eclint / js / rules / charset.spec.js View on Github external
var iconv = require('iconv-lite');
var common = require('../test-common');
var rule = require('./charset');
var linez = require('linez');
var expect = common.expect;
var reporter = common.reporter;
var context = common.context;
iconv.extendNodeEncodings();
// ReSharper disable WrongExpressionStatement
describe('charset rule', function () {
    beforeEach(function () {
        reporter.reset();
    });
    describe('check command', function () {
        it('reports out of range characters for latin1 setting', function () {
            rule.check(context, { charset: 'latin1' }, linez('foo\u0080bar'));
            expect(reporter).to.have.been.calledOnce;
            expect(reporter).to.have.been.calledWithExactly('Character out of latin1 range: \u0080');
        });
        it('remains silent on in-range characters for latin1 setting', function () {
            rule.check(context, { charset: 'latin1' }, linez('foo\u007Fbar'));
            expect(reporter).to.not.have.been.called;
        });
        it('reports invalid charsets', function () {
github jedmao / eclint / js / rules / charset.spec.js View on Github external
var iconv = require('iconv-lite');
var common = require('../test-common');
var rule = require('./charset');
var linez = require('linez');
var expect = common.expect;
var reporter = common.reporter;
var context = common.context;
var createLine = common.createLine;
var Doc = linez.Document;
iconv.extendNodeEncodings();
// ReSharper disable WrongExpressionStatement
describe('charset rule', function () {
    beforeEach(function () {
        reporter.reset();
    });
    describe('check command', function () {
        it('reports out of range characters for latin1 setting', function () {
            rule.check(context, { charset: 'latin1' }, linez('foo\u0080bar'));
            expect(reporter).to.have.been.calledOnce;
            expect(reporter).to.have.been.calledWithExactly('line 1, column: 4: character out of latin1 range: \u0080');
        });
        it('remains silent on in-range characters for latin1 setting', function () {
            rule.check(context, { charset: 'latin1' }, linez('foo\u007Fbar'));
            expect(reporter).to.not.have.been.called;
        });
        it('reports invalid charsets', function () {
github jedmao / eclint / lib / rules / charset.spec.ts View on Github external
var iconv = require('iconv-lite');

import common = require('../test-common');
import rule = require('./charset');
import linez = require('linez');

var expect = common.expect;
var reporter = common.reporter;
var context = common.context;

iconv.extendNodeEncodings();

// ReSharper disable WrongExpressionStatement
describe('charset rule', () => {

	beforeEach(() => {
		reporter.reset();
	});

	describe('check command', () => {

		it('reports out of range characters for latin1 setting',() => {
			rule.check(context, { charset: 'latin1' }, linez('foo\u0080bar'));
			expect(reporter).to.have.been.calledOnce;
			expect(reporter).to.have.been.calledWithExactly('Character out of latin1 range: \u0080');
		});
github DefinitelyTyped / DefinitelyTyped / iconv-lite / iconv-lite-tests.ts View on Github external
(() => {
	iconv.extendNodeEncodings();
	iconv.undoExtendNodeEncodings();
})();
github smaugmuds / _smaug_ / www / proxy / wsproxy.js View on Github external
JSON requests with { "chat": 1 } will be intercepted and handled
		by the basic in-proxy chat system.
	
*/

var u = require('util');
var net = require('net');
var http = require('http');
var zlib = require('zlib');
var fs = require('fs');

var ug = require("uglify-js");
var ws = require('websocket').server;
var iconv = require('iconv-lite');
iconv.extendNodeEncodings();

var first = (typeof srv == 'undefined');

process.chdir(__dirname);

stringify = function(A) {
	var cache = [];
	var val = JSON.stringify(A, function(k, v) {
	    if (typeof v === 'object' && v !== null) {
	        if (cache.indexOf(v) !== -1)
	            return;
	        cache.push(v);
	    }
	    return v;
    });
    return val;
github jasonrojas / node-captions / captions.js View on Github external
/**
 * Creates an instance of the node-captions module. This module allows you to convert from
 * one caption format to another. See the README.
 * @module node-captions
 * @version 0.0.1
 * @author Jason Rojas 
 * @see http://github.com/jasonrojas/node-captions
 * @returns An instance of the node-captions module.
 */

var iconv = require('iconv-lite');
iconv.extendNodeEncodings();

module.exports = {
    scc: require('./lib/scc.js'),
    srt: require('./lib/srt.js'),
    smi: require('./lib/smi.js'),
    vtt: require('./lib/vtt.js'),
    smpte_tt: require('./lib/smpte_tt.js'),
    ttml: require('./lib/ttml.js'),
    time: require('./lib/time.js'),
    macros: require('./lib/macros.js')
};
github plamzi / MUDPortal-Web-App / proxy / wsproxy.js View on Github external
JSON requests with { "chat": 1 } will be intercepted and handled
		by the basic in-proxy chat system.
	
*/

var u = require('util');
var net = require('net');
var http = require('http');
var zlib = require('zlib');
var fs = require('fs');

var ug = require("uglify-js");
var ws = require('websocket').server;
var iconv = require('iconv-lite');
iconv.extendNodeEncodings();

var first = (typeof srv == 'undefined');

process.chdir(__dirname);

stringify = function(A) {
	var cache = [];
	var val = JSON.stringify(A, function(k, v) {
	    if (typeof v === 'object' && v !== null) {
	        if (cache.indexOf(v) !== -1)
	            return;
	        cache.push(v);
	    }
	    return v;
    });
    return val;
github tgideas / motion / component / http.js View on Github external
var PORT = 1024;
var SITE_BASE = './';
var http = require('http');
var url=require('url');
var grunt = require('grunt');
var fs = require('fs');
var querystring = require("querystring");
var iconv = require("iconv-lite");

iconv.extendNodeEncodings();

var buildMotion = function(buildTask, filePath, response, charset, zepto, repackage){
  var readFromBuild = function(){
    fs.readFile(filePath, function(err, data){
        if(err){
            response.write('alert('+JSON.stringify(err).replace(/\\\\/g,'\\')+')');
        }else{
          data = iconv.encode(data, charset);
          if(zepto){
            fs.readFile('./src/zepto.js', function(err, zeptoData){
              response.write(iconv.encode(zeptoData+'\n', charset) + data);
              response.end();
            })
          }else{
            response.write(data);
            response.end();