diff --git a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Boolean.cs b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Boolean.cs index b19cee4e43ecc0..cb9af01b2327f3 100644 --- a/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Boolean.cs +++ b/src/libraries/System.Private.CoreLib/src/System/Buffers/Text/Utf8Parser/Utf8Parser.Boolean.cs @@ -33,22 +33,44 @@ public static bool TryParse(ReadOnlySpan source, out bool value, out int b if (source.Length >= 4) { - int dw = BinaryPrimitives.ReadInt32LittleEndian(source) & ~0x20202020; - if (dw == 0x45555254 /* 'EURT' */) + int dw = BinaryPrimitives.ReadInt32LittleEndian(source); + if (standardFormat == default(char) || standardFormat == 'G') { - bytesConsumed = 4; - value = true; - return true; - } + if (dw == 0x65757254 /* 'eurT' */) + { + bytesConsumed = 4; + value = true; + return true; + } - if (source.Length > 4) + if (source.Length > 4) + { + if (dw == 0x736C6146 /* 'slaF' */ && source[4] == 'e') + { + bytesConsumed = 5; + value = false; + return true; + } + } + } + else if (standardFormat == 'l') { - if (dw == 0x534c4146 /* 'SLAF' */ && (source[4] & ~0x20) == 'E') + if (dw == 0x65757274 /* 'eurt' */) { - bytesConsumed = 5; - value = false; + bytesConsumed = 4; + value = true; return true; } + + if (source.Length > 4) + { + if (dw == 0x736C6166 /* 'slaf' */ && source[4] == 'e') + { + bytesConsumed = 5; + value = false; + return true; + } + } } }