public string ZXing_Decode(Bitmap barcodeBitmap)
{
try
{
BarcodeReader reader = new BarcodeReader();
reader.Options = new ZXing.Common.DecodingOptions
{
CharacterSet = "ISO-8859-1"
};
var result = reader.Decode(barcodeBitmap);
if (result != null && result.Text != null)
{
byte[] isoBytes = Encoding.GetEncoding("ISO-8859-1").GetBytes(result.Text);
string value = Encoding.UTF8.GetString(isoBytes);
if (value.Contains("�"))
{
//是"�"这个特殊字符的乱码情况,使用gb2312
value = Encoding.GetEncoding("gb2312").GetString(isoBytes);
}
return value;
}
else
{
return null;
}
}
catch (Exception ex)
{
throw ex;
}
}