Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fujiharuka/shiftjis
https://github.com/fujiharuka/shiftjis
Last synced: 5 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/fujiharuka/shiftjis
- Owner: FujiHaruka
- Created: 2017-08-05T05:42:41.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-08-05T06:15:09.000Z (over 7 years ago)
- Last Synced: 2024-04-13T16:34:45.732Z (7 months ago)
- Language: JavaScript
- Size: 2.93 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# shiftjis
Simple iconv-lite wrapper to encode / decode Shift-JIS.
## Install
```
$ npm install shiftjis
```## Usage
```js
const fs = require('fs')
const {promisify} = require('util')
const readFileAsync = promisify(fs.readFile)
const {equal} = require('assert')
const shiftjis = require('../lib')describe('shiftjis', () => {
it('decode', async () => {
const data = await readFileAsync('misc/shift_jis.txt')
const str = shiftjis.decode(data)
equal(str.trim(), 'これはペンです。\nThis is a pen.')
})it('encode', async () => {
const str = 'これはペンです。'
const encoded = shiftjis.encode(str)
const decoded = shiftjis.decode(encoded)
equal(decoded, str)
})
})
```