(() => { // Convert from an encoded buffer to js string. const str: string = iconv.decode(new Buffer([0x68, 0x65, 0x6c, 0x6c, 0x6f]), 'win1251'); // Convert from js string to an encoded buffer. const buf: Buffer = iconv.encode("Sample input string", 'win1251'); // Check if encoding is supported const exists: boolean = iconv.encodingExists("us-ascii"); })();
encodingExists(value: string): boolean { return typeof value === "string" && encodingExists(value) }
/// <reference path="../typings/main.d.ts" /> import * as iconv from 'iconv-lite'; import { myspace } from './otherfile'; const str = iconv.decode(new Buffer([0x68, 0x65, 0x6c, 0x6f]), 'win1251'); console.log(str); console.log( iconv.decode(iconv.encode('Simple input string', 'win1251'), 'win1251') ); console.log('us-ascii => ', iconv.encodingExists('us-ascii')); new myspace.Hoge().sayHoge();