Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/fujiharuka/shiftjis


https://github.com/fujiharuka/shiftjis

Last synced: 5 days ago
JSON representation

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)
})
})
```