Commit daf0d3bc 刘韬

中文乱码非标处理

1 个父辈 7a4e9676
...@@ -43,7 +43,7 @@ namespace CodeLibrary ...@@ -43,7 +43,7 @@ namespace CodeLibrary
} }
cmbCount.SelectedIndex = 0; cmbCount.SelectedIndex = 0;
cmbCount.SelectedIndex = 0; cmbCount.SelectedIndex = 0;
LoadCamera(); //LoadCamera();
cmbCodeType.DataSource = HDCodeLearnHelper.codeTypeList; cmbCodeType.DataSource = HDCodeLearnHelper.codeTypeList;
if (HDCodeLearnHelper.codeTypeList.Count > 0) if (HDCodeLearnHelper.codeTypeList.Count > 0)
......
...@@ -78,6 +78,11 @@ namespace CodeLibrary ...@@ -78,6 +78,11 @@ namespace CodeLibrary
List<CodeInfo> array = DecodeCode(ho_Image, t, codeParamPath, codeCount); List<CodeInfo> array = DecodeCode(ho_Image, t, codeParamPath, codeCount);
codeList.AddRange(array.ToArray<CodeInfo>()); codeList.AddRange(array.ToArray<CodeInfo>());
} }
foreach (CodeInfo code in codeList)
{
code.CodeStr = code.GetCodeStr();
}
return codeList; return codeList;
} }
public static List<CodeInfo> DecodeCode(HObject ho_Image, string symbolType, string hv_model_path, int codeCount,int timeOut=1500) public static List<CodeInfo> DecodeCode(HObject ho_Image, string symbolType, string hv_model_path, int codeCount,int timeOut=1500)
...@@ -107,6 +112,7 @@ namespace CodeLibrary ...@@ -107,6 +112,7 @@ namespace CodeLibrary
ho_SymbolXLDs.Dispose(); ho_SymbolXLDs.Dispose();
// set_data_code_2d_param(DataCodeHandle, 'timeout', 200) // set_data_code_2d_param(DataCodeHandle, 'timeout', 200)
HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "timeout", timeOut); HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "timeout", timeOut);
//HOperatorSet.SetDataCode2dParam(hv_DataCodeHandle, "string_encoding", "raw");
if (codeCount <= 0) if (codeCount <= 0)
{ {
HOperatorSet.FindDataCode2d(ho_Image, out ho_SymbolXLDs, hv_DataCodeHandle, HOperatorSet.FindDataCode2d(ho_Image, out ho_SymbolXLDs, hv_DataCodeHandle,
...@@ -417,7 +423,9 @@ public class CodeInfo ...@@ -417,7 +423,9 @@ public class CodeInfo
/// <returns></returns> /// <returns></returns>
public static string Gb2312Correct(string text) public static string Gb2312Correct(string text)
{ {
if (HasChinese(text) == false) //string ascii= Encoding.ASCII.GetString(Encoding.ASCII.GetBytes(text));
//return ascii;
if (!HasChinese(text))
{ {
return text; return text;
} }
...@@ -429,9 +437,23 @@ public class CodeInfo ...@@ -429,9 +437,23 @@ public class CodeInfo
gb2312 = System.Text.Encoding.GetEncoding("gb2312"); gb2312 = System.Text.Encoding.GetEncoding("gb2312");
byte[] gb; byte[] gb;
gb = utf8.GetBytes(text); gb = utf8.GetBytes(text);
//utf8.GetString(System.Text.Encoding.Convert(utf8, gb2312, gb));
gb = System.Text.Encoding.Convert(utf8, gb2312, gb); gb = System.Text.Encoding.Convert(utf8, gb2312, gb);
//返回转换后的字符 //返回转换后的字符
return gb2312.GetString(gb);
string s = utf8.GetString(gb);
int sp = 0;
while (true)
{
sp = s.IndexOf("?", sp+1);
if (sp < 0)
break;
if (s.Substring(sp, 2) != "?;")
{
s = s.Insert(sp + 1, ";");
}
}
return s;
} }
} }
} }
...@@ -51,9 +51,8 @@ ...@@ -51,9 +51,8 @@
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet> <CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="log4net, Version=1.2.15.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL"> <Reference Include="log4net">
<SpecificVersion>False</SpecificVersion> <HintPath>..\dll\log4net.dll</HintPath>
<HintPath>..\..\dll\log4net.dll</HintPath>
</Reference> </Reference>
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
......
此文件类型无法预览
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!