convert-filename-ja
v1.0.3
Published
Convert a string to be able to use as a filename with Japanese characters.
Downloads
7
Maintainers
Readme
convert-filename-ja
Convert a string to be able to use as a filename with Japanese characters.
Install
npm install convert-filename-ja
Usage
convert
returns a string to safe use for filename.
- Remove control characters (0x00–0x1f and 0x80–0x9f)
- Remove reserved filenames on UNIX/Windows
- '.'
- '..'
- 'con', 'prn', 'aux', 'nul'
- 'com1', 'com2', 'com3', 'com4', 'com5', 'com6', 'com7', 'com8', 'com9'
- 'lpt1', 'lpt2', 'lpt3', 'lpt4', 'lpt5', 'lpt6', 'lpt7', 'lpt8', 'lpt9'
- Remove prefix space and suffix space and dot
- Convert reserved characters ( / ? < > ¥ \ : * | " ) to Japanese double byte characters.
- Remove characters over 255
const converter = require('convert-filename-ja');
const parentDir = converter.convert('..'); // ''
const convertDoublebyte = converter.convert('filename<2018/06/08>.txt.'); // 'filename<2018/06/08>.txt'
const nonProcessed = converter.convert('filenme.txt'); // 'filename.txt'
Refer
https://github.com/parshap/node-sanitize-filename