Comments (11)
Set the binarytext
flag to true
. By default, UTF-16 strings are assumed and converted to UTF-8.
from bwip-js.
Hi @metafloor, thanks for the quick response.
Now I set the option as follow:
bwipjs.toCanvas(canvas, {
bcid: 'pdf417',
text: myText,
binarytext: true,
scaleX: 3,
scaleY: 2,
columns: 7,
eclevel: 4,
parsefnc: true
where "myText" is always of this form: "^ECI000017" + valueString.
Unfortunatly nothing have changed. Same problems:
world 'Schaumbërg' is read as 'Schaumbërg'
and
euro symbl is read as 'â ¬'
from bwip-js.
What version of bwip-js are you using? binarytext
is a very new option, only available in 4.1+.
Also, please provide the output from this code for a failing myText
string:
console.log(myText.replace(/[\x80-\xff]/g, ($) => {
let cd = $.charCodeAt(0);
if (cd < 128) {
return $;
} else {
return '\\x' + cd.toString(16);
}
}));
I need the output for my testing and to verify the 8859 encoding.
from bwip-js.
Hi @metafloor, we used last version of 3.x. I just udated to 4.1.1 but we have a problem with the toCanvas method.
Just to clarify we are developing in angular 14, using node.js and typescript.
After the update we are no more able to find the toCanvas method inside bwipjs module.
"Property 'toCanvas' does not exist on type 'typeof BwipJs'."
from bwip-js.
Likely pulling in the node-js package. Does angular support the exports
map in package.json
?
from bwip-js.
finally we were able to work with the version 4.1.1. adding binarytext to true we receive the following error:
"Error: bwip-js: 16-bit chars not allowed with binarytext"
without we have as output from your console.log this:
^ECI00001710 13 Schaumb\xebrg-von-und-zu-Schaumburg-und-Rad\xebberg Fri\xebdrich-Wilhelm-Karl-Gustav-Justus-Gotfried 19510712 20341231 101308719 LKK Schlesw-Holst. und H 38 H030170228 1 00 02 398212400 776299002 20210704 Prof. habil. Dr. med Grossherzog von und zu der 53639 K\xf6nigswinter Pfaffenschlag bei Waidhofen an der Thaya Allee 155155133 D 20210704 1234 2 1 06151/1111111 J09 G, G00.0 V kBB €-Zeichensatztest Y/9/2107/36/001
from bwip-js.
If you look closely at the console output, you will see a euro character in €-Zeichensatztest
. That is probably a utf-16 codepoint.
from bwip-js.
Sure I can see the euro character =)
But that was the output before to pass the string inside the toCanvas method.
If we have a text without euro symbol (using binarytext = true) we don't have problem with any characters and also umlaut chars are displayed correctly in the barcode. (So this fix the first problem that we have).
But,
if we use a text that has a euro symbol with binarytext = true the ToCanvas method return an error at this point inside the library:
if (opts.binarytext) {
// THE TEXT DOESN T PASS THIS .test
if (/[\u0100-\uffff]/.test(text)) {
throw new Error('bwip-js: 16-bit chars not allowed with binarytext');
}
} else if (/[\u0080-\uffff]/.test(text)) {
text = unescape(encodeURIComponent(text));
}
we tried to pass the text preprocessing it with a library that convert it to iso-8859-15, or pass it in utf-8 but in both ways we have the same error with euro symbol.
from bwip-js.
Moreover, if I was able to partially understand the code, if no 16-bit chars are allowed with binarytext option I think there is a problem with € symbol in any case. Is it right?
from bwip-js.
The issue is that you are not passing in a iso-8859-15 encoded string. The euro symbol is being passed in as unicode U+20AC. You need to convert it to \xa4
per iso-8859-15.
from bwip-js.
Ok I understand the situation.
We investigate a little bit and it seems that both the libraries that we tried to convert to iso 8859-15 effectively convert the euro as uncode U+20AC mainwhile all the other symbols in the form \x'something'.
I think there is all.
Thanks a lot for your support and really really thanks for your time!
from bwip-js.
Related Issues (20)
- suggest toSVG use viewBox instead width and height attributes HOT 2
- how to new line text HOT 3
- [React] Cannot find "toCanvas" HOT 5
- Maintain a Proper Changelog
- Lack of `default` condition in the exports map HOT 18
- Escaping "(" and ")" using ^040 and & ^41 in gs1 datamatrix encoder ends up with AI syntax error HOT 22
- SVG related functions are not represented in the .d.ts files HOT 4
- In React APP toBuffer import issue HOT 1
- when i use this to create an dataMatrix code, how can i set my code correct level, i set by this, but looks not useful HOT 2
- Compatibility with IE11 HOT 6
- Property 'toCanvas' does not exist on type 'typeof BwipJs'. HOT 4
- QrCode to zpl HOT 5
- Property 'toCanvas' does not exist on type 'typeof BwipJs' HOT 18
- nodejs 20.10.0 generate a different barcode compare when I use nodejs 20.9.0 HOT 3
- Datamatrix generation fo binary data after 3.4.0 has extra bytes HOT 3
- 4.2.0 will not generate the same barcode as 3.0.1 HOT 3
- please tag when doing a npm publish HOT 1
- Uncaught ReferenceError: BwipJs is not defined - Runtime error HOT 2
- New option showbearer via BWIP 2023-07-2 HOT 4
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 bwip-js.