Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
GeneralClassLibrary
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit e20c1059
由
LN
编写于
2020-08-24 16:37:26 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1
1 个父辈
53debe60
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
41 行增加
和
0 行删除
CodeLibraryProject/CodeLibrary/FrmCodeDecode.cs
CodeLibraryProject/CodeLibrary/HDCodeHelper.cs
CodeLibraryProject/CodeLibrary/ZXingCodeHelper.cs
CodeLibraryProject/CodeLibrary/FrmCodeDecode.cs
查看文件 @
e20c105
...
...
@@ -164,6 +164,7 @@ namespace CodeLibrary
foreach
(
CodeInfo
code
in
list
)
{
txtResult
.
Text
+=
"\r\n"
+
""
+
code
.
CodeType
+
" (X:"
+
code
.
X
+
",Y:"
+
code
.
Y
+
") "
+
code
.
CodeStr
;
txtResult
.
Text
+=
"\r\n"
+
""
+
code
.
CodeType
+
" (X:"
+
code
.
X
+
",Y:"
+
code
.
Y
+
") "
+
code
.
GetCodeStr
();
}
}
else
...
...
CodeLibraryProject/CodeLibrary/HDCodeHelper.cs
查看文件 @
e20c105
...
...
@@ -6,6 +6,7 @@ using System.Drawing.Imaging;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
using
System.Text.RegularExpressions
;
using
System.Threading.Tasks
;
using
System.Windows.Forms
;
namespace
CodeLibrary
...
...
@@ -332,5 +333,41 @@ public class CodeInfo
this
.
X
=
x
;
this
.
Y
=
y
;
}
public
string
GetCodeStr
()
{
return
Gb2312Correct
(
CodeStr
);
}
/// <summary>
/// 判断字符串中是否包含中文
/// </summary>
/// <param name="str">需要判断的字符串</param>
/// <returns>判断结果</returns>
public
static
bool
HasChinese
(
string
str
)
{
return
Regex
.
IsMatch
(
str
,
@"[\u4e00-\u9fa5]"
);
}
/// <summary>
/// utf8文字用gb2312格式显示时候乱码,需要转换为gb2312
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public
static
string
Gb2312Correct
(
string
text
)
{
if
(
HasChinese
(
text
)
==
false
)
{
return
text
;
}
//声明字符集
System
.
Text
.
Encoding
utf8
,
gb2312
;
//utf8
utf8
=
System
.
Text
.
Encoding
.
GetEncoding
(
"utf-8"
);
//gb2312
gb2312
=
System
.
Text
.
Encoding
.
GetEncoding
(
"gb2312"
);
byte
[]
gb
;
gb
=
utf8
.
GetBytes
(
text
);
gb
=
System
.
Text
.
Encoding
.
Convert
(
utf8
,
gb2312
,
gb
);
//返回转换后的字符
return
gb2312
.
GetString
(
gb
);
}
}
}
CodeLibraryProject/CodeLibrary/ZXingCodeHelper.cs
查看文件 @
e20c105
...
...
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using
System.Drawing
;
using
System.Linq
;
using
System.Text
;
using
System.Text.RegularExpressions
;
using
System.Threading.Tasks
;
using
ZXing
;
using
ZXing.Common
;
...
...
@@ -202,6 +203,8 @@ namespace CodeLibrary
}
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论