首次提交
This commit is contained in:
25
SCADA/Core/PLC_R.cs
Normal file
25
SCADA/Core/PLC_R.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace DC_A95
|
||||
{
|
||||
public class PLC_R
|
||||
{
|
||||
/// <summary>
|
||||
/// 清理PLC字符串乱码(统一入口,支持object参数)
|
||||
/// 过滤不可见字符,保留可打印ASCII和中文等有效字符
|
||||
/// </summary>
|
||||
public static string GetString_CleanGarbled(object input)
|
||||
{
|
||||
if (input == null) return "";
|
||||
string str = input.ToString();
|
||||
if (string.IsNullOrEmpty(str)) return "";
|
||||
var sb = new StringBuilder();
|
||||
foreach (char c in str)
|
||||
{
|
||||
if (c >= 0x20 && c < 0xFFFE) sb.Append(c);
|
||||
}
|
||||
return sb.ToString().Trim();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user