QRCode二维条码开发(代码)_2011.05.24
2011-05-24 11:09
190 查看
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;
}
//函数功能:字母数字模式下将输入的数据转换成信息码
//参数说明:
//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二维条码开发
- QRCode二维条码开发(计算版本信息)_2011.06.01
- QRCode二维条码开发_2011.05.23
- QRCode二维条码开发(计算格式信息)_2011.05.25
- 《编写高质量代码-Web前端开发修改之道》笔记--第二章 团队合作
- 让你的代码量减少3倍!使用kotlin开发Android
- iOS开发:统计xcode代码的行数
- nodejs 后台开发 和C++代码开发
- 大数据开发进阶笔记——HBase的常用原子操作Java代码
- html5游戏开发教程实战:五子棋、四子棋、围棋、翻转棋四种对弈游戏,仅仅100行代码
- Android-NDK开发之基础--Android JNI实例代码(四)-- JNI中的异常处理实例代码
- 在SharePoint中无代码开发InfoPath应用: 一个测试Web Service的工具
- IOS开发UI—纯代码实现控件及其基本属性
- iOS开发总结之代码规范
- C开发机顶盒实战应用代码片段
- 《编写高质量代码-Web前端开发修改之道》笔记--第三章 高质量的HTML
- Cocos2d-x使用Javascript开发js绑定C++<代码示例>
- 微信开发——2、代码模式下创建菜单
- javascrit开发的基本代码结构的