有毛病我吧code(code 128) [英] Something wrong with my barcode (Code 128)

查看:181
本文介绍了有毛病我吧code(code 128)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是很容易使用,产生的9 吧code进行 3 字体()

It was easy to generate a 3 of 9 barcode using Font()

Font f = new Font("Free 3 of 9", 80);
this.Font = f;

Label l = new Label();
l.Text = "*STACKOVERFLOW*";
l.Size = new System.Drawing.Size(800, 600);
this.Controls.Add(l);

this.Size = new Size(800, 600);

其工作。我看到了吧code和即时通讯能够扫描。现在,我想用别的东西,如 code 128 对于我需要安装的字体(完成),只是改变

Its working. I see the barcode and Im able to scan it. Now I would like to use something else, like Code 128 For that I need to install the Font (done) and just change

字体F =新的字体(自由3 9,80); 字体F =新的字体(code 128,80);

之后,我看到我的窗口酒吧code。的问题是,Im不能够扫描这一点。我想那是因为我不使用正确的开始停止标签栏code。当我知道有必须始终是一个开始/停止字符或什么的。对于3 9 IST的*作code 128林不知道。在维基有开始code A ,所以我尝试

After that I see a barcode on my window. The problem is that Im not able to scan that. And I think thats because I dont use the right start and stop tag for the barcode. As I understood there have to be always a start/stop char or whatever. For 3 of 9 ist the * for Code 128 im not sure. On wiki there is Start Code A so I tried

字体F =新的字体(<启动code A>测试<停止>中,80); 字体˚F =新的字体(<启动code A>测试<停止code A>中,80); 等等......我不是能够扫描输出。由于扫描仪找不到启动和停止字符。有任何想法吗?谢谢

Font f = new Font("<Start Code A>test<Stop>", 80);, Font f = new Font("<Start Code A>test<Stop Code A>", 80); and so on... Im not able to scan the output. Because the scanner cannot find the start and stop char. Any ideas? Thank you

推荐答案

code 128可以重新$ P $。这是棘手超过3/9,但因为你必须包括它需要基于对吧code中的内容进行动态计算最终的校验字符。也有3种不同的版本,每个都有不同的起始字符。

Code 128 can be represented with a font totally fine. It's trickier than 3 of 9 though because you have to include a checksum character at the end which needs to be dynamically computed based on the content of the barcode. There are also 3 different versions which each have a different start char.

在换句话说吧code需要布置出这样的:

In other words the barcode needs to be laid out like:

[start char][barcode][checksum][stop char]

的code128的好处是,它比3的9更​​加简洁。

The benefit of code128 is that it is much more concise than 3 of 9.

此页面帮我制定出算法我计算校验和。

This page helped me work out the algorithm to compute my checksums.

该算法的一个非常普遍的概述是:

A very general overview of the algorithm is:

  1. 的吧code每个角色获得分配给它一个特定的值 根据字符是什么以及它位于 酒吧code。

  1. Each character of the barcode gets a specific value assigned to it depending on what the character is and where it is located in the barcode.

所有)以上的相加。在1的值

All of the values in 1) above are added together.

获取模103价值总量中2)以上。

Get the modulus 103 value of the total in 2) above.

在大多数情况下,校验字符将是ASCII code为:(模值 加上32)在3确定)以上。

In most cases, the checksum char will be the ASCII code for: (modulus value plus 32) as determined in 3) above.

有一些细微的差别,我最终需要来创建此算法的所有的东西(没有问题)的JavaScript。对于自己的未来参考,并表现出一定的细微差别,这是是什么样子:

There were some nuances, I ended up needing to create this algorithm in javascript of all things (no questions). For my own future reference and to show some of the nuances this is what it looked like:

/*
 * This is the variable part of my barcode, I append this to a 
 * static prefix later, but I need to perform logic to compute the 
 * checksum for this variable. There is logic earlier that enforces 
 * this variable as a 9 character string containing only digits.   
 */ 
var formIncrement = // a 9 char "digit" string variable

/*
 * Dynamically compute the total checksum value (before modulus) 
 * for the variable part of my barcode, I will need to get a modulus 
 * from this total when I am done. If you need a variable number of 
 * characters in your barcodes or if they are not all digits 
 * obviously something different would have to be done here.  
 */ 
var incrementCS = ((parseInt(formIncrement.charAt(0)) + 16) * 7) +
                  ((parseInt(formIncrement.charAt(1)) + 16) * 8) +
                  ((parseInt(formIncrement.charAt(2)) + 16) * 9) +
                  ((parseInt(formIncrement.charAt(3)) + 16) * 10) +
                  ((parseInt(formIncrement.charAt(4)) + 16) * 11) +
                  ((parseInt(formIncrement.charAt(5)) + 16) * 12) +
                  ((parseInt(formIncrement.charAt(6)) + 16) * 13) +
                  ((parseInt(formIncrement.charAt(7)) + 16) * 14) + 
                  ((parseInt(formIncrement.charAt(8)) + 16) * 15);

/*
 * 452 is the total checksum for my barcodes static prefix (600001), 
 * so it doesn't need to be computed dynamically, I just add it to 
 * the variable checksum total determined above and then get the 
 * modulus of that sum:  
 */ 
var checksum = (452 + incrementCS) % 103


var barcode = "š600001" + formIncrement

/*
 * The 0 and the 95 - 102 cases had to be defined explicitly because 
 * their checksum figures do not line up with the javascript char 
 * codes for some reason (see the code 128 definition table in the 
 * linked page) otherwise we simply need to get the charCode of the 
 * checksum + 32. I also tack on the stop char here. 
 */ 
switch (checksum) {
    case 0 :
    barcode += "€œ";
    break;
    case 95 :
    barcode += "‘œ";
    break;
    case 96 :
    barcode += "’œ";
    break;
    case 97 :
    barcode += ""œ";
    break;
    case 98 :
    barcode += ""œ";
    break;
    case 99 :
    barcode += "•œ";
    break;
    case 100 :
    barcode += "–œ";
    break;
    case 101 :
    barcode += "—œ";
    break;
    case 102 :
    barcode += "˜œ";
    break;
    default :
    barcode += String.fromCharCode(checksum + 32) + "œ";
}

return barcode;

您可能会注意到,我开始和结束字符在我的例子(S,OE)似乎并没有与链接的页面上显示的那些匹配。如果我还记得我认为这是因为我有一些不规范的code128的字体和这些字符转换为正确的。

You may notice that my start and stop chars in my example (š, œ) don't seem to match up with the ones shown on the linked page. If I remember I think it was because I had some non-standard code128 font and these chars translated to the correct ones.

修改

我在我的文档签回。它看起来像我从字体这里。随着该字体特别,用上面的算法,我只是做了code128b吧$ C $下测试它出来štestwœ,它扫描的罚款。你的校验算法似乎是工作的罚款,因为我们都有是W ,但它看起来像你的启动和停止codeS是关闭,如果你得到:ÌtestwÎ

I checked back in my documentation. It looks like I got the font from right here. With that font specifically and using the algorithm above, I just made a code128b barcode for test which came out to štestwœ, it scanned fine. Your checksum algorithm seems to be working fine because we both have w but it looks like your start and stop codes are off if you are getting: ÌtestwÎ.

我做了点寻找,我使用,因为我有一种感觉,不同品牌的code128的字体可以实现不同的字符重新present的启动和停止一样吧code字型酒吧codeS。

I made a point to look for the same barcode font that I am using because I have a feeling that different brands of code128 fonts may implement different characters to represent the start and stop barcodes.

这篇关于有毛病我吧code(code 128)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆