Comments (4)
You could also do it a bit easier:
const escpos = new EscPosEncoder();
const printValue = escpos.initialize()
.line('This is a test line')
.encode();
// this is a string representation
const result = Buffer.from(printValue.buffer).toString();
If you are using this from browser, then I recomend also using tihs lib: https://github.com/feross/buffer
from escposencoder.
I am searching for this feature too.
from escposencoder.
@umutesen I found a solution which might help you
https://www.npmjs.com/package/jszpl
from escposencoder.
I found a small function to handle decoding Uint8Array:
function Utf8ArrayToStr(array) {
var out, i, len, c;
var char2, char3;
out = "";
len = array.length;
i = 0;
while(i < len) {
c = array[i++];
switch(c >> 4)
{
case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7:
// 0xxxxxxx
out += String.fromCharCode(c);
break;
case 12: case 13:
// 110x xxxx 10xx xxxx
char2 = array[i++];
out += String.fromCharCode(((c & 0x1F) << 6) | (char2 & 0x3F));
break;
case 14:
// 1110 xxxx 10xx xxxx 10xx xxxx
char2 = array[i++];
char3 = array[i++];
out += String.fromCharCode(((c & 0x0F) << 12) |
((char2 & 0x3F) << 6) |
((char3 & 0x3F) << 0));
break;
}
}
return out;
}
Source here
from escposencoder.
Related Issues (20)
- CP874 Mapping Error
- Image .. Error: ReferenceError: document is not defined
- CommonJS or AMD dependencies can cause optimization bailouts HOT 1
- Can not print thai character HOT 3
- New npm package HOT 7
- Cannot install on M1 Mac (ARM64) HOT 2
- Add display text parameter when printing barcode
- Publish a new version with auto encode and with the table functionality HOT 2
- Print image issue ( incomplete printing / encode error ) HOT 6
- Pure Browser JS Example HOT 3
- Failed to execute 'getImageData' HOT 1
- How To Insert Data Array in to Encoder? HOT 1
- cutting HOT 3
- How to print a horizontal line and font size increase
- Hello, how can I print Chinese HOT 1
- esc-pos-encoder error with NODE_MODULE_VERSION HOT 1
- I'm sorry but
- Add multiline support for "newLine" command
- Table with border and table auto layout
- Image printed with empty spaces in between HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from escposencoder.