Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

codepage

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

codepage - npm Package Compare versions

Comparing version 1.3.7 to 1.3.8

26

cputils.js

@@ -35,3 +35,5 @@ /* cputils.js (C) 2013-2014 SheetJS -- http://sheetjs.com */

var cca = function cca(x){ return x.charCodeAt(0); };
if(typeof Buffer !== 'undefined') {
var has_buf = (typeof Buffer !== 'undefined');
if(has_buf) {
var mdl = 1024, mdb = new Buffer(mdl);

@@ -71,2 +73,3 @@ var make_EE = function make_EE(E){

out.length = j;
out = out.slice(0,j);
} else {

@@ -130,2 +133,3 @@ out = Buffer(len);

out.length = k;
out = out.slice(0,k);
} else if(Buffer.isBuffer(data)) {

@@ -145,2 +149,3 @@ for(i = k = 0; i < len; ++i) {

out.length = k;
out = out.slice(0,k);
} else {

@@ -244,3 +249,3 @@ for(i = k = 0; i < len; i++) {

var encache = function encache() {
if(typeof Buffer !== 'undefined') {
if(has_buf) {
if(cpdcache[sbcs_cache[0]]) return;

@@ -271,3 +276,3 @@ var i, s;

var decache = function decache() {
if(typeof Buffer !== 'undefined') {
if(has_buf) {
if(!cpdcache[sbcs_cache[0]]) return;

@@ -295,5 +300,5 @@ sbcs_cache.forEach(cp_decache);

if(cpecache[cp] !== undefined) { last_enc = cpecache[last_cp=cp]; return last_enc(data, ofmt); }
if(typeof Buffer !== 'undefined' && Buffer.isBuffer(data)) data = data.toString('utf8');
if(has_buf && Buffer.isBuffer(data)) data = data.toString('utf8');
var len = data.length;
var out = typeof Buffer !== 'undefined' ? new Buffer(4*len) : [], w, i, j = 0, c, tt, ww;
var out = has_buf ? new Buffer(4*len) : [], w, i, j = 0, c, tt, ww;
var C = cpt[cp], E, M;

@@ -310,3 +315,3 @@ if(C && (E=C.enc)) for(i = 0; i < len; ++i, ++j) {

case "utf8":
if(typeof Buffer !== 'undefined' && typeof data === "string") { out = new Buffer(data, M); j = out.length; break; }
if(has_buf && typeof data === "string") { out = new Buffer(data, M); j = out.length; break; }
for(i = 0; i < len; ++i, ++j) {

@@ -333,3 +338,3 @@ w = data[i].charCodeAt(0);

case "ascii":
if(typeof Buffer !== 'undefined' && typeof data === "string") { out = new Buffer(data, M); j = out.length; break; }
if(has_buf && typeof data === "string") { out = new Buffer(data, M); j = out.length; break; }
for(i = 0; i < len; ++i, ++j) {

@@ -342,3 +347,3 @@ w = data[i].charCodeAt(0);

case "utf16le":
if(typeof Buffer !== 'undefined' && typeof data === "string") { out = new Buffer(data, M); j = out.length; break; }
if(has_buf && typeof data === "string") { out = new Buffer(data, M); j = out.length; break; }
for(i = 0; i < len; ++i) {

@@ -395,2 +400,3 @@ w = data[i].charCodeAt(0);

out.length = j;
out = out.slice(0,j);
if(typeof Buffer === 'undefined') return (ofmt == 'str') ? out.map(sfcc).join("") : out;

@@ -436,3 +442,3 @@ if(ofmt === undefined || ofmt === 'buf') return out;

case "ascii":
if(typeof Buffer !== 'undefined' && Buffer.isBuffer(data)) return data.toString(M);
if(has_buf && Buffer.isBuffer(data)) return data.toString(M);
for(i = 0; i < len; i++) out[i] = String.fromCharCode(data[i]);

@@ -443,3 +449,3 @@ k = len; break;

if(len >= 2 && data[0] == 0xFF) if(data[1] == 0xFE) i = 2;
if(typeof Buffer !== 'undefined' && Buffer.isBuffer(data)) return data.toString(M);
if(has_buf && Buffer.isBuffer(data)) return data.toString(M);
j = 2;

@@ -446,0 +452,0 @@ for(; i < len; i+=j) {

{
"name": "codepage",
"version": "1.3.7",
"version": "1.3.8",
"author": "SheetJS",

@@ -5,0 +5,0 @@ "description": "pure-JS library to handle codepages",

# Codepages for JS
[Codepages](https://en.wikipedia.org/wiki/Codepage) are character encodings. In
many contexts, single-byte character sets are used in lieu of standard multibyte
Unicode encodings. They use 256 characters with a simple mapping.
many contexts, single- or double-byte character sets are used in lieu of Unicode
encodings. The codepages map between characters and numbers.

@@ -84,4 +84,32 @@ [unicode.org](http://www.unicode.org/Public/MAPPINGS/) hosts lists of mappings.

## Building the script
## Rolling your own script
The `make.sh` script in the repo can take a manifest and generate JS source.
Usage:
bash make.sh path_to_manifest output_file_name JSVAR
where
- `JSVAR` is the name of the exported variable (generally `cptable`)
- `output_file_name` is the output file (e.g. `cpexcel.js`, `cptable.js`)
- `path_to_manifest` is the path to the manifest file.
The manifest file is expected to be a CSV with 3 columns:
<codepage number>,<source>,<size>
If a source is specified, it will try to download the specified file and parse.
The file format is expected to follow the format from the unicode.org site.
The size should be `1` for a single-byte codepage and `2` for a double-byte
codepage. For mixed codepages (which use some single- and some double-byte
codes), the script assumes the mapping is a prefix code and generates efficient
JS code.
Generated scripts only include the mapping. `cat` a mapping with `cputils.js`
to produce a complete script like `cpexcel.full.js`.
## Building the complete script
This script uses [voc](npm.im/voc). The script to build the codepage tables and

@@ -98,6 +126,7 @@ the JS source is `codepage.md`, so building is as simple as `voc codepage.md`.

| CP# | Information | Description |
| --: | ----------- | ----------- |
| --: | :----------: | :---------- |
| 37| unicode.org |IBM EBCDIC US-Canada
| 437| unicode.org |OEM United States
| 500| unicode.org |IBM EBCDIC International
| 620| NLS |Mazovia (Polish) MS-DOS
| 708|MakeEncoding.cs|Arabic (ASMO 708)

@@ -123,2 +152,3 @@ | 720|MakeEncoding.cs|Arabic (Transparent ASMO); Arabic (DOS)

| 875| unicode.org |IBM EBCDIC Greek Modern
| 895| NLS |Kamenický (Czech) MS-DOS
| 932| unicode.org |Japanese Shift-JIS

@@ -125,0 +155,0 @@ | 936| unicode.org |Simplified Chinese GBK

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc