Files
WC-CZGKJ/SCADA/Core/PLC_R.cs
2026-05-11 11:09:04 +08:00

26 lines
723 B
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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();
}
}
}