// 去除UTF8文本中BOM标记 public static string TrimBOM(string fileText) { if (string.IsNullOrEmpty(fileText)) return ""; byte[] bytes = Encoding.UTF8.GetBytes(fileText); if (bytes.Length >= 3 && bytes[0] == 239 && bytes[1] == 187 && bytes[2] == 191) { fileText = Encoding.UTF8.GetString(bytes, 3, bytes.Length - 3); } return fileText; }