How to use the windows-1252.decode function in windows-1252

To help you get started, we’ve selected a few windows-1252 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 srveit / mechanize-js / lib / mechanize / agent.js View on Github external
body.copy(body2, 0, 2);
          response.body = body2.toString('utf16le');
        } else if (body[0] === 0xFF && body[1] === 0xFE) {
          // UTF-16 little-endian
          const body2 = Buffer.allocUnsafe(body.length - 2);
          body.copy(body2, 0, 2);
          response.body = body2.toString('utf16le');
        } else {
          // UTF-8
          response.body = body.toString('binary');
        }
      }
      if (options.fixCharset) {
        response.body = response.body.replace('charset=utf-16le', 'utf-8');
        if (response.body.match(/charset=windows-1252/)) {
          response.body = windows1252.decode(response.body);
        }
      }
      const page = newPage({
        uri,
        response,
        body: response.body,
        code: response.statusCode,
        agent
      });

      addResponseCookies({
        response,
        uri: new URL(uri),
        page
      });
      history.push(page);

windows-1252

A robust windows-1252 encoder/decoder written in JavaScript.

MIT
Latest version published 3 years ago

Package Health Score

51 / 100
Full package analysis

Popular windows-1252 functions