JSPM

iconv-lite-loader

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q25725F
  • License MIT

A webpack loader for non-utf-8-files

Package Exports

  • iconv-lite-loader

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (iconv-lite-loader) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

iconv-lite-loader

This is a webpack loader for opening files in arbitrary encodings.

ChangeLog

v1.0.0 - Initial release

Basic Usage

npm install iconv-lite-loader

The loader itself request the input as raw data, decodes it and exports the resulting string. The iconv-lite library is used for that, because it doesn't need native bindings and claims to be faster than iconv. It could be used with the "complete" iconv library with a few changes. If you need it, please open a issue.

//in webpack.config.js

module.exports = {
    module: {
        loaders: [
            { test: /\.txt(\?.*)?$/, loader: "inconv-lite?inputEncoding=iso-8859-1"}
        ]
    }
};

This will set the default encoding of txt files to ISO-8859-1. You can override this (per request) by using a parameter:

text = require("chinese.txt?inputEncoding=gb2312")

Requirements

The only real dependency is the iconv-lite library. This should hopefully build easily, even on windows. If not, please let me hear about it.