Installations
npm install @i-xi-dev/ms932-encoder
Developer Guide
Typescript
No
Module System
ESM
Node Version
20.11.0
NPM Version
10.2.4
Score
77.9
Supply Chain
99.5
Quality
77.8
Maintenance
100
Vulnerability
100
License
Contributors
Unable to fetch Contributors
Languages
TypeScript (100%)
Developer
i-xi-dev
Download Statistics
Total Downloads
9,017
Last Day
7
Last Week
35
Last Month
154
Last Year
5,714
GitHub Statistics
121 Commits
1 Watching
1 Branches
1 Contributors
Package Meta Information
Latest Version
2.1.9
Package Id
@i-xi-dev/ms932-encoder@2.1.9
Unpacked Size
343.59 kB
Size
84.25 kB
File Count
122
NPM Version
10.2.4
Node Version
20.11.0
Publised On
16 Jun 2024
Total Downloads
Cumulative downloads
Total Downloads
9,017
Last day
0%
7
Compared to previous day
Last week
169.2%
35
Compared to previous week
Last month
42.6%
154
Compared to previous month
Last year
309.6%
5,714
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
3
@i-xi-dev/ms932-encoder
A JavaScript Windows-31J encoder, implements Shift_JIS encoder defined in WHATWG Encoding Standard.
Requirement
Ms932.Encoder
class
Chrome | Edge | Firefox | Safari | Deno | Node.js |
---|---|---|---|---|---|
✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
Ms932.EncoderStream
class
Ms932.EncoderStream
requires
TransformStream
.
Chrome | Edge | Firefox | Safari | Deno | Node.js |
---|---|---|---|---|---|
✅ | ✅ | ✅ 102+ | ✅ 14.1+ | ✅ | ✅ 16.5+ |
Installation
npm
1$ npm i @i-xi-dev/ms932-encoder@2.1.9
1import { Ms932 } from "@i-xi-dev/ms932-encoder";
CDN
Example for UNPKG
1import { Ms932 } from "https://www.unpkg.com/@i-xi-dev/ms932-encoder@2.1.9/esm/mod.js";
Usage
Ms932.Encoder
class
The Ms932.Encoder
implements the
TextEncoder
interface.
1const encoder = new Ms932.Encoder(); 2 3encoder.encode("あいうえお"); 4// → Uint8Array[ 0x82, 0xA0, 0x82, 0xA2, 0x82, 0xA4, 0x82, 0xA6, 0x82, 0xA8 ] 5 6const bytes = new Uint8Array(10); 7const { read, written } = encoder.encodeInto("あいうえお", bytes); 8// → read: 5 9// written: 10 10// bytes: Uint8Array[ 0x82, 0xA0, 0x82, 0xA2, 0x82, 0xA4, 0x82, 0xA6, 0x82, 0xA8 ]
Encoding error handling
1const encoder = new Ms932.Encoder({ fatal: false }); // default 2 3encoder.encode("𩸽"); 4// → Uint8Array[ 0x3F ]
1const encoder = new Ms932.Encoder({ replacementChar: "■" }); 2 3encoder.encode("𩸽"); 4// → Uint8Array[ 0x81, 0xA1 ]
1const encoder = new Ms932.Encoder({ fatal: true }); 2 3encoder.encode("𩸽"); 4// → throws TypeError.
Ms932.EncoderStream
class
The Ms932.EncoderStream
implements
TextEncoderStream
interface.
1const encoderStream = new Ms932.EncoderStream(); 2 3// readableStream: ReadableStream<string> 4// writableStream: WritableStream<Uint8Array> 5readableStream.pipeThrough(encoderStream).pipeTo(writableStream);
Examples
FAQ
Q: Where is Ms932.Decoder?
A: Browsers and Node.js implement the
Shift_JIS decoder. Use a
TextDecoder
.
1const decoder = new TextDecoder("shift_jis");
No vulnerabilities found.
No security vulnerabilities found.