彩票走势图

如何生成和识别UTF 8(Unicode)字符的条形码

原创|其它|编辑:郝浩|2012-10-18 15:53:34.000|阅读 586 次

概述:utf - 8是一个可变长度的Unicode字符编码。它可以代表任何标准的Unicode字符。您可以生成非英文字符条形码,比如阿拉伯语、拉丁语、希腊语等。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

utf - 8是一个可变长度的Unicode字符编码。它可以代表任何标准的Unicode字符。您可以生成非英文字符条形码,比如阿拉伯语、拉丁语、希腊语等。下面就给出使用Aspose.BarCode的示例代码:

[C#]

Bitmap imgBarcode = null;
// set license
Aspose.BarCode.License license = new Aspose.BarCode.License();
license.SetLicense("c:\\Aspose.Total.lic");
try
{
    // generate the barcode
    BarCodeBuilder objBarCodeBuilder = new BarCodeBuilder();
    objBarCodeBuilder.SymbologyType = Aspose.BarCode.Symbology.MacroPdf417;
    // set the codetext by converting it into unicode byte array
    byte[] byteArray = Encoding.Unicode.GetBytes("منحة");
    objBarCodeBuilder.SetCodeText(byteArray);
    imgBarcode = objBarCodeBuilder.GenerateBarCodeImage();
    imgBarcode.Save("c:\\barcodes.png");
    // recognize the above barcode
    BarCodeReader reader = new BarCodeReader("c:\\barcodes.png");
    while(reader.Read())
    {
        Encoding unicode = Encoding.Unicode;
        // get the characters array from the bytes
        char[] unicodeChars = new char[unicode.GetCharCount(reader. GetCodeBytes(), 0, reader. GetCodeBytes().Length)];
        unicode.GetChars(reader. GetCodeBytes(), 0, reader. GetCodeBytes().Length, unicodeChars, 0);
        // build unicode string
        string strCodeText = new string(unicodeChars);
        System.Console.WriteLine(strCodeText);
    }
    reader.Close();
}
catch (Exception ex)
{
    System.Console.WriteLine("No BarCode found");
}

[VB.NET]

Dim imgBarcode As Bitmap = Nothing
' set license
Dim license As Aspose.BarCode.License = New Aspose.BarCode.License()
license.SetLicense("c:\Aspose.Total.lic")
Try
	' generate the barcode
	Dim objBarCodeBuilder As BarCodeBuilder = New BarCodeBuilder()
	objBarCodeBuilder.SymbologyType = Aspose.BarCode.Symbology.MacroPdf417
	' set the codetext by converting it into unicode byte array
	Dim byteArray As Byte() = Encoding.Unicode.GetBytes("منحة")
	objBarCodeBuilder.SetCodeText(byteArray)
	imgBarcode = objBarCodeBuilder.GenerateBarCodeImage()
	imgBarcode.Save("c:\barcodes.png")
	' recognize the above barcode
	Dim reader As BarCodeReader = New BarCodeReader("c:\barcodes.png")
	Do While reader.Read()
		Dim [unicode] As Encoding = Encoding.Unicode
		' get the characters array from the bytes
		Dim unicodeChars As Char() = New Char([unicode].GetCharCount(reader. GetCodeBytes(), 0, reader. GetCodeBytes().Length) - 1){}
		[unicode].GetChars(reader. GetCodeBytes (), 0, reader. GetCodeBytes ().Length, unicodeChars, 0)
		' build unicode string
		Dim strCodeText As String = New String(unicodeChars)
		System.Console.WriteLine(strCodeText)
	Loop
       reader.Close()
Catch ex As Exception
	System.Console.WriteLine("No BarCode found")
End Try
 

 


标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP