public static bool TryParseBoolean(ReadOnlySpan <byte> text, EncodingData encoding, TextFormat format, out bool value, out int bytesConsumed) { bytesConsumed = 0; value = default(bool); if (text.Length < 1) { return(false); } if (encoding.IsInvariantUtf8) { byte firstCodeUnit = text[0]; if (firstCodeUnit == '1') { bytesConsumed = 1; value = true; return(true); } else if (firstCodeUnit == '0') { bytesConsumed = 1; value = false; return(true); } else if (PrimitiveParser.IsTrue(text)) { bytesConsumed = 4; value = true; return(true); } else if (PrimitiveParser.IsFalse(text)) { bytesConsumed = 5; value = false; return(true); } else { return(false); } } return(false); }