Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

arrowing/a2u

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

11 Commits

Repository files navigation

ANSI TO UNICODE

Convert ansi buffer to character(ucs2 encodings), or convert character to ansi encodings in NodeJs.

  • Faster than iconv-lite.
  • Don't depend other module.
  • The volume is so small.

NPM Stats

Install

npm install a2u

Usage

Decode API

var fs = require('fs');
var buf = fs.readFileSync('demo.txt'); //txt's encoding is ANSI, the content is "I(我) love(爱) you(你)."
var a2u = require('a2u');
var str, newBuf;
// Convert from an encoded buffer to js string.
str = a2u.decode(buf);
console.log(str);//I(我) love(爱) you(你).
// If you want convert to buffer with ucs2 encoding, the second arg for method(decode) will be true.
newBuf = a2u.decode(buf, true);
console.log('ANSI buffer : ', buf);
console.log('ucs2 buffer : ', newBuf);
console.log(newBuf.toString('ucs2'));//I(我) love(爱) you(你).

Encode API

var fs = require('fs');
var a2u = require('a2u');
var str = "I(我) love(爱) you(你).";
var buf;
// If string
buf = a2u.encode(str);
console.log('ANSI buffer : ', buf);
// If buffer
buf = a2u.encode( new Buffer(str, 'ucs2') );
console.log('ANSI buffer : ', buf);
// Write to file
fs.writeFileSync('ansi.txt', buf);

About

ANSI TO UNICODE

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

AltStyle によって変換されたページ (->オリジナル) /