public static bool TryParse (byte[] buffer, int available, out ByteOrderMark bom) { if (buffer.Length >= 2) { for (int i = 0; i < table.Length; i++) { bool matched = true; if (available < table[i].Bytes.Length) continue; for (int j = 0; j < table[i].Bytes.Length; j++) { if (buffer[j] != table[i].Bytes[j]) { matched = false; break; } } if (matched) { bom = table[i]; return true; } } } bom = null; return false; }
public static bool TryParse(byte[] buffer, int available, out ByteOrderMark bom) { if (buffer.Length >= 2) { for (int i = 0; i < table.Length; i++) { bool matched = true; if (available < table[i].Bytes.Length) { continue; } for (int j = 0; j < table[i].Bytes.Length; j++) { if (buffer[j] != table[i].Bytes[j]) { matched = false; break; } } if (matched) { bom = table[i]; return(true); } } } bom = null; return(false); }
public static bool TryParse(Stream stream, out ByteOrderMark bom) { byte[] buffer = new byte [4]; int nread; if ((nread = stream.Read(buffer, 0, buffer.Length)) < 2) { bom = null; return(false); } return(TryParse(buffer, nread, out bom)); }
public ProjectWriter (ByteOrderMark bom) { encoding = bom != null ? Encoding.GetEncoding (bom.Name) : null; ByteOrderMark = bom; }
public static bool TryParse (Stream stream, out ByteOrderMark bom) { byte[] buffer = new byte [4]; int nread; if ((nread = stream.Read (buffer, 0, buffer.Length)) < 2) { bom = null; return false; } return TryParse (buffer, nread, out bom); }