C语言实现的Code128编码
//code128编码值数组,,每一个字符占11个单位表示,代码中用两个byte表示(取后11位bit)
static uint16_t s_code128_encode_set[] ={
0x6cc,0x66c,0x666,0x498,0x48c,0x44c,0x4c8,0x4c4,0x464,0x648,
0x644,0x624,0x59c,0x4dc,0x4ce,0x5cc,0x4ec,0x4e6,0x672,0x65c,
0x64e,0x6e4,0x674,0x76e,0x74c,0x72c,0x726,0x764,0x734,0x732,
0x6d8,0x6c6,0x636,0x518,0x458,0x446,0x588,0x468,0x462,0x688,
0x628,0x622,0x5b8,0x58e,0x46e,0x5d8,0x5c6,0x476,0x776,0x68e,
0x62e,0x6e8,0x6e2,0x6ee,0x758,0x746,0x716,0x768,0x762,0x71a,
0x77a,0x642,0x78a,0x530,0x50c,0x4b0,0x486,0x42c,0x426,0x590,
0x584,0x4d0,0x4c2,0x434,0x432,0x612,0x650,0x7ba,0x614,0x47a,
0x53c,0x4bc,0x49e,0x5e4,0x4f4,0x4f2,0x7a4,0x794,0x792,0x6de,
0x6f6,0x7b6,0x578,0x51e,0x45e,0x5e8,0x5e2,0x7a8,0x7a2,0x5de,
0x5ee,0x75e,0x7ae,0x684,0x690,0x69c,0x18EB
};
#define CODE128_MEX_LEN 30
static uint16_t code128_temp[CODE128_MEX_LEN] = {0};
#define CODE128_ONE_ELEMENT_SIZE 11
STATUS_TYPE code128C_encode(const uint8_t *src,uint8_t length,uint8_t *out)
{
int i = 0;
int j = 0;
uint8_t chr_temp = 0;
uint32_t check_digit = 0;
uint16_t *p_out = code128_temp;
memset(code128_temp,0,CODE128_MEX_LEN);
p_out[0] = 0x69c;
p_out++;
check_digit += 105;
for(i = 0,j = 0;i < length;i += 2,j++ )
{
if(src[i] < '0' || src[i] > '9' || src[i+1] < '0' || src[i+1] > '9')
{
return STATUS_INVALID_CHAR;
}
chr_temp = (src[i] - '0')*10 + src[i + 1] - '0';
check_digit += (j + 1)*chr_temp;
p_out[j] = s_code128_encode_set[chr_temp];
}
check_digit %=103;
p_out[j] = s_code128_encode_set[check_digit];
p_out[j+1] = 0x18EB;
return STATUS_OK;
}
下一篇: 在C语言中玩猜数字游戏
推荐阅读
-
C语言内存管理的重要性
-
使用opencv3和C++编程语言实现简单目标跟踪的Tracker
-
C#版本实现:探究游戏2048的核心算法
-
C语言编写的2048游戏实现
-
Java 8新特性探究(十三)JavaFX 8新特性以及开发2048游戏-JavaFX历史## 跟java在服务器端和web端成绩相比,桌面一直是java的软肋,于是Sun公司在2008年推出JavaFX,弥补桌面软件的缺陷,请看下图JavaFX一路走过来的改进 从上图看出,一开始推出时候,开发者需使用一种名为JavaFX Script的静态的、声明式的编程语言来开发JavaFX应用程序。因为JavaFX Script将会被编译为Java bytecode,程序员可以使用Java代码代替。 JavaFX 2.0之后的版本摒弃了JavaFX Script语言,而作为一个Java API来使用。因此使用JavaFX平台实现的应用程序将直接通过标准Java代码来实现。 JavaFX 2.0 包含非常丰富的 UI 控件、图形和多媒体特性用于简化可视化应用的开发,WebView可直接在应用中嵌入网页;另外 2.0 版本允许使用 FXML 进行 UI 定义,这是一个脚本化基于 XML 的标识语言。 从JDK 7u6开始,JavaFx就与JDK捆绑在一起了,JavaFX团队称,下一个版本将是8.0,目前所有的工作都已经围绕8.0库进行。这是因为JavaFX将捆绑在Java 8中,因此该团队决定跳过几个版本号,迎头赶上Java 8。 ##JavaFx8的新特性 ## ###全新现代主题:Modena 新的Modena主题来替换原来的Caspian主题。不过在Application的start方法中,可以通过setUserAgentStylesheet(STYLESHEET_CASPIAN)来继续使用Caspian主题。 参考http://fxexperience.com/2013/03/modena-theme-update/ ###JavaFX 3D 在JavaFX8中提供了3D图像处理API,包括Shape3D (Box, Cylinder, MeshView, Sphere子类),SubScene, Material, PickResult, LightBase (AmbientLight 和PointLight子类),SceneAntialiasing等。Camera类也得到了更新。从JavaDoc中可以找到更多信息。 ###富文本 强化了富文本的支持 ###TreeTableView ###日期控件DatePicker 增加日期控件 ###用于 CSS 结构的公共 API
-
C语言实现2048游戏的完整代码
-
C++实现的大顶堆和小顶堆的堆排序算法
-
C++实现的大顶堆:重新表达原标题
-
C语言实现大顶堆:策略和代码解析
-
C语言编写的“猜数字“小游戏