QRCode二维条码开发(代码)_2011.05.24
来源:互联网 发布:剑网3开重制版数据 编辑:程序博客网 时间:2024/04/26 23:07
11:09:36
//函数功能:字母数字模式下将输入的数据转换成信息码
//参数说明:
//strInput -- 原始输入数据
//strVersionNum -- 当前版本号
//strErrLevel -- 当前纠错等级
//返回值:strDataCode -- 返回编码后的码字
CString CQRCodeDlg::AlphaNumericMode(CString strInput, CString strVersionNum, CString strErrLevel)
{
AfxMessageBox("进入到字母数字模式编码函数!");
CString strDataCode;//输入数据按规则转换后的码字,也是此函数的返回值
CString strText = "123456FDedfdg";
CString strTemp;
strText = strInput;
int nLength = 0;//输入字符串的长度
int nValue = 0;
int nVersionNum = 2;//版本号
int nBits;//字符计数指示符的位数
char buffer[20];//存放11位二进制的缓冲区
char chEncodeMode = '2';//代表字母数字编码模式
strText.MakeUpper();
char cInput[2];
strVersionNum.Format("%d",nVersionNum);
nLength = strText.GetLength();
for(int i=0;i<nLength;i++)
{
if(i%2 != 0)
{
if(strText[i] >= '0' && strText[i] <= '9')
cInput[1] = strText[i] - 48;
else if (strText[i] >= 'A' && strText[i] <= 'Z')
cInput[1] = strText[i] - 55;
else if (strText[i] == 32)/*space空格*/
cInput[1] = 36;
else if (strText[i] == 36)/*$符号*/
cInput[1] = 37;
else if (strText[i] == 37)/*%符号*/
cInput[1] = 38;
else if (strText[i] == 42)/*星号*/
cInput[1] = 39;
else if (strText[i] == 43)/*加号*/
cInput[1] = 40;
else if (strText[i] == 45)/*减号*/
cInput[1] = 41;
else if (strText[i] == 46)/*点.*/
cInput[1] = 42;
else if (strText[i] == 47)/*斜杠*/
cInput[1] = 43;
else if (strText[i] == 58)/*冒号*/
cInput[1] = 44;
nValue = cInput[0]*45 + cInput[1];
_itoa(nValue,buffer,2);
strTemp.Format("%011s",buffer);
strDataCode += strTemp;
}
else if(i%2 == 0)
{
if(strText[i] >= '0' && strText[i] <= '9')
cInput[0] = strText[i] - 48;
else if (strText[i] >= 'A' && strText[i] <= 'Z')
cInput[0] = strText[i] - 55;
else if (strText[i] == 32)/*space空格*/
cInput[0] = 36;
else if (strText[i] == 36)/*$符号*/
cInput[0] = 37;
else if (strText[i] == 37)/*%符号*/
cInput[0] = 38;
else if (strText[i] == 42)/*星号*/
cInput[0] = 39;
else if (strText[i] == 43)/*加号*/
cInput[0] = 40;
else if (strText[i] == 45)/*减号*/
cInput[0] = 41;
else if (strText[i] == 46)/*点.*/
cInput[0] = 42;
else if (strText[i] == 47)/*斜杠*/
cInput[0] = 43;
else if (strText[i] == 58)/*冒号*/
cInput[0] = 44;
}
}
if(nLength%2 !=0)
{
nValue = cInput[0];
_itoa(nValue,buffer,2);
strTemp.Format("%06s",buffer);
strDataCode += strTemp;
}
_itoa(nLength,buffer,2);
nBits = IndicatorBits(chEncodeMode,nVersionNum);
switch(nBits)
{
case 9:
strTemp.Format("%09s",buffer);
break;
case 11:
strTemp.Format("%011s",buffer);
break;
case 13:
strTemp.Format("%013s",buffer);
break;
}
strDataCode = "0010" + strTemp + strDataCode;//模式指示符+字符计数指示符+数据
return strDataCode;
}
- QRCode二维条码开发(代码)_2011.05.24
- QRCode二维条码开发(代码)_2011.05.24
- QRCode二维条码开发(计算格式信息)_2011.05.25
- QRCode二维条码开发(计算版本信息)_2011.06.01
- QRCode二维条码开发
- C#打印二维条码QRCode
- Delphi开发二维条码的方法
- PB开发二维条码的方法
- 一维条码,二维条码
- 用DELPHI工具编制开发生成二维条码
- Windows应用程序创建QRCode条码控件QRCode Fontware
- PDF417二维条码/二维码
- 二维条码 QR Code
- PDF417二维条码详解
- 二维条码目前应用
- 二维条码/二维码
- 二维条码生成
- 二维条码PDF417译码技术
- execCommand
- URL对某些特殊字符串的转义
- Samba服务下Ubuntu 10.10与Windows系统共享
- Android Native C Log
- 定点数与浮点数
- QRCode二维条码开发(代码)_2011.05.24
- TSM 备份 归档和 恢复
- Android APN开发流程分析(一)
- Spring 2.X 中AOP的使用浅析
- Fedora 15 正式版可以下载啦!
- VS2008下使用Linq To Entity的Skip().Take()分页查询时遇到数据结果不对的问题
- [ASP.NET(C#)] - 解决了防止用户重复登陆和session超时
- execCommand
- BackgroundWorker 类