private int getCharIndex(char c) throws InvalidAtributeException{ if( c >= '0' && c <= '9' ){ return c - 48; } else if( c >= 'A' && c <= 'Z' ){ return c - 55; } else if( c == '-' ){ return 36; } else if( c == '.' ){ return 37; } else if( c == ' ' ){ return 38; } else if( c == '$' ){ return 39; } else if( c == '/' ){ return 40; } else if( c == '+' ){ return 41; } else if( c == '%' ){ return 42; } else { throw new InvalidAtributeException("[Code39] The text contains unsuported chars."); } }
private int getChar(int c) throws InvalidAtributeException{ if( c >= 0 && c <= 9 ){ return c + 48; } else if( c >= 10 && c <= 35){ return c + 55; } else if( c == 36 ){ return 45; } else if( c == 37 ){ return 46; } else if( c == 38 ){ return 32; } else if( c == 39 ){ return 36; } else if( c == 40 ){ return 47; } else if( c == 41 ){ return 43; } else if( c == 42 ){ return 37; } else { throw new InvalidAtributeException("[Code39] The text contains unsuported chars."); } }
public String computeCheckSum(String texto) throws InvalidAtributeException { int check = 0; for( int i = 0; i < texto.length(); i++ ){ check += getCharIndex(texto.charAt(i)); } return (Character.valueOf((char)getChar(check%43)).toString()); }
@Test public void testComputeCheckSum() throws InvalidAtributeException { String code = "TEXT"; System.out.println(computeCheckSum(code)); }
相关推荐
根据code39码的规则,实现了用sqlserver的sql代码生成code39的校验码的标量函数。
code39条形码code39条形码code39条形码code39条形码code39条形码
code39,code128,等code系列, EAN条形码 包含MFC,Java 源代码
代码检查 CheckStyle-IDEA,可以本地加载该插件,避免因为墙的原因长时间无法下载带来的困扰,新增自用优化后的Code Check文件
code check 讲述的是程序员需要注意的事项,给测试人员提供了一部分理论而已
通过GDI+技术实现Code39码,解决Barcode studio控件扫码异常问题。尚未封装成控件,有兴趣的同学可以自己封装。
生成code39和code128的BMP图片示例代码,Code128支持AB两种类型,能自动根据字串优化成C类型
生成Code39(extend)条形码源码 源码描述: 一、源码特点 C#GDI+绘制Code39条形码 。网上开源的众多,但却都是根据内容和长宽来确定模块宽度。本次由于某需求需要根据模块宽度以及数据多少来确定条形码的长宽。识别...
code39字体 code39字体 code39字体code39字体
CODE128和CODE39条形码生成打印代码CODE128和CODE39条形码生成打印代码
Code 39 条形码 详细介绍 标准型Code 39 条形码(Standard Code 39):数据内容包含有0~9数字,A~Z英文字母,”+”,”-“,”*”,”/”,”%”,”$”,”.”以及space空白,共44个字符. 完全型Code 39 条形码(Full ASCII Code...
linux环境下,用于计算md5sum的小工具,通常也能轻易移植到嵌入系统
Qt 5.7 实现生成Code39条码,独立的类可直接移植,生成的图片参数可设置,完整的Demo程序,直接编译可运行
C# 生成code39条形码代码 供大家分享
this is a outer sum matlab code, can be use to computer the outer sum of two arrays
C#生成Code39源码
实现条码的打印,可设置打印高度、条码宽度,支持code39、code128等种类