How to use the text-encoding.TextDecoder function in text-encoding

To help you get started, we’ve selected a few text-encoding 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 mudchina / webtelnet / webtelnet-proxy.js View on Github external
reset: function() {
    this.io = null;
    this.logTraffic = false;

    this.isRunning = false;
    this.timer = 0;
    this.lastTick = 0;

    this.sockets = {};  // sid -> socket
    this.socketsCount = 0;
    
    this.port = 23;
    this.host = '127.0.0.1';
    this.decoder = new TextDecoder('utf-8');
    return this;
  },
github jeka-kiselyov / mdict / mdict-parser.js View on Github external
attrs.Encoding = attrs.Encoding || 'UTF-16';
      
      _searchTextLen = (attrs.Encoding === 'UTF-16') 
                          ?   function(dv, offset) {
                                offset = offset;
                                var mark = offset;
                                while (dv.getUint16(offset++)) { /* scan for NUL */ };
                                return offset - mark;
                          } : function(dv, offset) {
                                offset = offset;
                                var mark = offset;
                                while (dv.getUint8(offset++)) { /* scan for NUL */ }
                                return offset - mark - 1;
                          };
      
      _decoder = new TextDecoder(attrs.Encoding || 'UTF-16LE');

      _bpu = (attrs.Encoding === 'UTF-16') ? 2 : 1;
      
      if (parseInt(attrs.GeneratedByEngineVersion, 10) >= 2.0) {
        _v2 = true;
        _tail = _bpu;

          // HUGE dictionary file (>4G) is not supported, take only lower 32-bit
        _readNum     = function(scanner) { return scanner.forward(4), scanner.readInt(); };
        _readShort   = function(scanner) { return scanner.readUint16(); };
        _checksum_v2 = function(scanner) { return scanner.checksum(); };
      } else {
        _tail = 0;
      }
      
      // keyword index decrypted?
github yoichiro / actions-tools / src / conversation.ts View on Github external
_handleScreenOut(data: AssistResponse, response: ConversationResponse): void {
        if (data.screen_out) {
            if (data.screen_out.format === 1) { // HTML
                // const html = Buffer.from(data.screen_out.data!.buffer).toString()
                const html = new te.TextDecoder("utf-8").decode(data.screen_out.data!)
                response.screenOut = {
                    format: data.screen_out.format,
                    data: html,
                }
            }
        }
    }
github EOSIO / eosio-explorer / packages / api-rpc / src / api / push_action.ts View on Github external
export default async (query: {
  endpoint: string,
  account_name: string,
  private_key: string,
  actor: string,
  permission: string,
  action_name: string,
  payload: any
}) => {
  try{
    let { endpoint, account_name, private_key, actor, permission, action_name, payload } = query;

    const rpc = new JsonRpc(endpoint);
    const signatureProvider = new JsSignatureProvider([private_key]);
    const api = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder() });


    if (account_name === "eosio" && action_name==="setabi"){
      const buffer = new Serialize.SerialBuffer({
        textEncoder: api.textEncoder,
        textDecoder: api.textDecoder,
      });

      let abi = payload.abi;
      const abiDefinition = api.abiTypes.get('abi_def');
      // need to make sure abi has every field in abiDefinition.fields
      // otherwise serialize throws error
      abi = abiDefinition!.fields.reduce(
          (acc, { name: fieldName }) => Object.assign(acc, { [fieldName]: acc[fieldName] || [] }),
          abi,
      );
github emailjs / emailjs-mime-parser / src / mimeparser-unit.js View on Github external
it('should decode unencoded 7bit input', function () {
    var fixture = 'Content-Type: text/plain\r\n' +
      '\r\n' +
      'xxxx\r\n' +
      'yyyy'
    const root = parse(fixture)
    expect(new TextDecoder('utf-8').decode(root.content)).to.equal('xxxx\nyyyy')
  })
github emailjs / emailjs-mime-parser / src / mimeparser-unit.js View on Github external
it('should ignore charset for plaintext attachment', function () {
    var fixture = 'Content-Type: text/plain; charset="latin_1"\r\n' +
      'Content-Disposition: attachment\r\n' +
      'Content-Transfer-Encoding: quoted-printable\r\n' +
      '\r\n' +
      'l=F5petam'
    var expectedText = 'lõpetam'
    const root = parse(fixture)
    expect(new TextDecoder('iso-8859-1').decode(root.content)).to.equal(expectedText)
  })
github mudchina / webtelnet / webtelnet-proxy.js View on Github external
setCharset: function(cs) {
    this.charset = cs;
    this.decoder = new TextDecoder(cs);
    return this;
  },
github eosdac / eosdac-api / eosdac-processor.js View on Github external
constructor() {
        this.config = loadConfig();

        const rpc = new JsonRpc(this.config.eos.endpoint, {fetch});
        this.api = new Api({
            rpc,
            signatureProvider: null,
            chainId: this.config.chainId,
            textDecoder: new TextDecoder(),
            textEncoder: new TextEncoder(),
        });

        this.logger = require('./connections/logger')('eosdac-processor', this.config.logger);
    }
github eosdac / eosdac-api / watchers / referendums.js View on Github external
constructor() {
        this.config = loadConfig();
        this.db = connectMongo(this.config);
        const rpc = new JsonRpc(this.config.eos.endpoint, {fetch});
        this.api = new Api({
            rpc,
            signatureProvider: null,
            chainId: this.config.chainId,
            textDecoder: new TextDecoder(),
            textEncoder: new TextEncoder(),
        });

        this.logger = require('../connections/logger')('watcher-proposals', this.config.logger);
    }
github coloz / blinker-simple-app / src / app / device-manager.service.ts View on Github external
export function transcoding(buf) {
  let message;
  if (checkCodeUtf8(buf))
    message = new TextDecoder("utf8").decode(new Uint8Array(buf.slice(0, buf.indexOf(10))));
  else
    message = new TextDecoder("gb18030").decode(new Uint8Array(buf.slice(0, buf.indexOf(10))));
  return message;
}

text-encoding

Polyfill for the Encoding Living Standard's API.

(Unlicense OR Apache-2.0)
Latest version published 6 years ago

Package Health Score

56 / 100
Full package analysis