コード例 #1
0
ファイル: ByteOrderMark.cs プロジェクト: Kalnor/monodevelop
		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;
		}
コード例 #2
0
        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);
        }
コード例 #3
0
        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));
        }
コード例 #4
0
			public ProjectWriter (ByteOrderMark bom)
			{
				encoding = bom != null ? Encoding.GetEncoding (bom.Name) : null;
				ByteOrderMark = bom;
			}
コード例 #5
0
ファイル: ByteOrderMark.cs プロジェクト: Kalnor/monodevelop
		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);
		}