您的位置:首页 > 数据库

条码十六进制数据转换成字符串的SQL_CLR代码

2013-09-05 18:24 239 查看
           string sBarcodeHex;   //十六进制

            string sBarcodeAscii="";    //条码返回ASCII字符串

            sBarcodeHex=Info.ToString();

            //当条码值为空时不处理

            if ((sBarcodeHex.Length) > 0)

            {

                int i = 0;

                string cAscii;

                while (i < sBarcodeHex.Length)

                {

                    if (sBarcodeHex.Length >= i + 2)

                        cAscii = sBarcodeHex.Substring(i, 2);

                     else

                        cAscii = sBarcodeHex.Substring(i, 1);

                    int value = Convert.ToInt32(cAscii, 16);

                    char charValue = (char)value;

                    sBarcodeAscii = sBarcodeAscii + charValue.ToString();

                    i = i + 2;

                }

                Info = sBarcodeAscii;

            }

            else

            {

                Info = "空";

            }

            Dsp1 = "条码输入:";

            Dsp2 = Info;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  数据库