BarcodeSettings.DetectEncoding
Contents
[
Hide
]BarcodeSettings.DetectEncoding property
The flag which force engine to detect codetext encoding for Unicode codesets. Default value is true.
public bool DetectEncoding { get; set; }
Property Value
The flag which force engine to detect codetext encoding for Unicode codesets
Examples
This sample shows how to detect text encoding on the fly if DetectEncoding is enabled
[C#]
using (MemoryStream ms = new MemoryStream())
{
using (BarcodeGenerator generator = new BarcodeGenerator(EncodeTypes.QR))
{
generator.SetCodeText("Слово", Encoding.UTF8);
generator.Save(ms, BarCodeImageFormat.Png);
}
//detects encoding for Unicode codesets is enabled
ms.Position = 0;
using (BarCodeReader reader = new BarCodeReader(ms, DecodeType.QR))
{
reader.BarcodeSettings.DetectEncoding = true;
foreach (BarCodeResult result in reader.ReadBarCodes())
Console.WriteLine("BarCode CodeText: " + result.CodeText);
}
//detect encoding is disabled
ms.Position = 0;
using (BarCodeReader reader = new BarCodeReader(ms, DecodeType.QR))
{
reader.BarcodeSettings.DetectEncoding = false;
foreach (BarCodeResult result in reader.ReadBarCodes())
Console.WriteLine("BarCode CodeText: " + result.CodeText);
}
}
[VB.NET]
Using ms As New MemoryStream
Using generator As New BarcodeGenerator(EncodeTypes.QR, "Слово")
generator.SetCodeText("Слово", System.Text.Encoding.UTF8)
generator.Save(ms, BarCodeImageFormat.Png)
End Using
'detects encoding for Unicode codesets is enabled
ms.Position = 0
Using reader As New BarCodeReader("c:\test.png", DecodeType.Code39, DecodeType.Code128)
reader.BarcodeSettings.DetectEncoding = True
For Each result As BarCodeResult In reader.ReadBarCodes()
Console.WriteLine("BarCode CodeText: " + result.CodeText)
Next
End Using
'detect encoding is disabled
ms.Position = 0
Using reader As New BarCodeReader("c:\test.png", DecodeType.Code39, DecodeType.Code128)
reader.BarcodeSettings.DetectEncoding = False
For Each result As BarCodeResult In reader.ReadBarCodes()
Console.WriteLine("BarCode CodeText: " + result.CodeText)
Next
End Using
End Using
See Also
- class BarcodeSettings
- namespace Aspose.BarCode.BarCodeRecognition
- assembly Aspose.BarCode