From 6f8c4302a9802742107707caeb00a8141a3cd662 Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Mon, 14 Nov 2016 14:17:27 -0800 Subject: [PATCH 1/2] text formatting does not use EncodingData --- .../Text/Formatting/FormattingDataProvider.cs | 4 +- .../System/Text/Formatting/CompositeFormat.cs | 2 +- .../Text/Formatting/IOutputExtensions.cs | 24 +- .../Text/Formatting/ITextOutputExtensions.cs | 8 +- .../System/Text/Http/HttpHeaderBuffer.cs | 2 +- .../System/Text/Json/JsonDynamicObject.cs | 18 +- .../System/Text/EncodingData.cs | 27 +- .../System/Text/Formatting/FloatFormatter.cs | 2 +- .../Text/Formatting/IntegerFormatter.cs | 4 +- .../Text/Formatting/PrimitiveFormatter.cs | 184 ++-- .../Formatting/PrimitiveFormatter_time.cs | 112 +-- .../Formatting/PrimitiveFormatter_uuid.cs | 56 +- .../Text/Parsing/PrimitiveParser_uint.cs | 12 +- .../CustomCulture.cs | 4 +- .../CustomTypeFormatting.cs | 2 +- .../PerformanceTests.cs | 2 +- .../ParserTests.cs | 936 +++++++++--------- .../PrimitiveParserTests.cs | 2 +- 18 files changed, 697 insertions(+), 704 deletions(-) diff --git a/src/System.Text.Formatting.Globalization/System/Text/Formatting/FormattingDataProvider.cs b/src/System.Text.Formatting.Globalization/System/Text/Formatting/FormattingDataProvider.cs index 6dcce6a4ec0..7e466f49498 100644 --- a/src/System.Text.Formatting.Globalization/System/Text/Formatting/FormattingDataProvider.cs +++ b/src/System.Text.Formatting.Globalization/System/Text/Formatting/FormattingDataProvider.cs @@ -45,7 +45,7 @@ private static EncodingData CreateEncoding(string localeId, Stream resourceStrea byte[] idBytes = new byte[maxIdLength]; int idByteCount; - if (!localeId.TryFormat(new Span(idBytes), EncodingData.InvariantUtf8, out idByteCount)) + if (!localeId.TryFormat(new Span(idBytes), EncodingData.TextEncoding.Utf8, out idByteCount)) { throw new Exception("bad locale id"); } @@ -92,7 +92,7 @@ private static EncodingData CreateEncoding(string localeId, Stream resourceStrea Array.Copy(data, stringStart, utf16digitsAndSymbols[stringIndex], 0, stringLength); } - return new EncodingData(utf16digitsAndSymbols, EncodingData.Encoding.Utf16); + return new EncodingData(utf16digitsAndSymbols, EncodingData.TextEncoding.Utf16); } static ushort ReadUInt16At(byte[] data, int ushortIndex) diff --git a/src/System.Text.Formatting/System/Text/Formatting/CompositeFormat.cs b/src/System.Text.Formatting/System/Text/Formatting/CompositeFormat.cs index 6287e88505d..c6a26f85d15 100644 --- a/src/System.Text.Formatting/System/Text/Formatting/CompositeFormat.cs +++ b/src/System.Text.Formatting/System/Text/Formatting/CompositeFormat.cs @@ -141,7 +141,7 @@ static void Append(this TFormatter formatter, string whole, int inde for (int i = 0; i < count; i++) { int bytesWritten; - while (!whole[i+index].TryFormat(buffer, formatter.Encoding, out bytesWritten)) + while (!whole[i+index].TryFormat(buffer, formatter.Encoding.Encoding, out bytesWritten)) { Debug.Assert(false, "this should never happen"); // because I pre-resized the buffer to 4 bytes per char at the top of this method. } diff --git a/src/System.Text.Formatting/System/Text/Formatting/IOutputExtensions.cs b/src/System.Text.Formatting/System/Text/Formatting/IOutputExtensions.cs index 3b358c9cabb..a26cfd16aa4 100644 --- a/src/System.Text.Formatting/System/Text/Formatting/IOutputExtensions.cs +++ b/src/System.Text.Formatting/System/Text/Formatting/IOutputExtensions.cs @@ -25,7 +25,7 @@ public static class IOutputExtensions return true; } - public static void Append(this TFormatter formatter, string value, EncodingData.Encoding encoding) where TFormatter : IOutput + public static void Append(this TFormatter formatter, string value, EncodingData.TextEncoding encoding) where TFormatter : IOutput { if (value.Length < 256) { while (!formatter.TryAppend(value, encoding)) { @@ -47,61 +47,61 @@ public static void Append(this TFormatter formatter, string value, E } } - public static bool TryAppend(this TFormatter formatter, string value, EncodingData.Encoding encoding) where TFormatter : IOutput + public static bool TryAppend(this TFormatter formatter, string value, EncodingData.TextEncoding encoding) where TFormatter : IOutput { int bytesWritten; - if (!value.TryFormat(formatter.Buffer, encoding == EncodingData.Encoding.Utf8 ? EncodingData.InvariantUtf8 : EncodingData.InvariantUtf16, out bytesWritten)) { + if (!value.TryFormat(formatter.Buffer, encoding, out bytesWritten)) { return false; } formatter.Advance(bytesWritten); return true; } - public static void Append(this TFormatter formatter, ReadOnlySpan value, EncodingData.Encoding encoding) where TFormatter : IOutput + public static void Append(this TFormatter formatter, ReadOnlySpan value, EncodingData.TextEncoding encoding) where TFormatter : IOutput { while (!formatter.TryAppend(value, encoding)) { formatter.Enlarge(); } } - public static bool TryAppend(this TFormatter formatter, ReadOnlySpan value, EncodingData.Encoding encoding) where TFormatter : IOutput + public static bool TryAppend(this TFormatter formatter, ReadOnlySpan value, EncodingData.TextEncoding encoding) where TFormatter : IOutput { int bytesWritten; - if (!value.TryFormat(formatter.Buffer, encoding==EncodingData.Encoding.Utf8?EncodingData.InvariantUtf8:EncodingData.InvariantUtf16, out bytesWritten)) { + if (!value.TryFormat(formatter.Buffer, encoding, out bytesWritten)) { return false; } formatter.Advance(bytesWritten); return true; } - public static void Append(this TFormatter formatter, char value, EncodingData.Encoding encoding) where TFormatter : IOutput + public static void Append(this TFormatter formatter, char value, EncodingData.TextEncoding encoding) where TFormatter : IOutput { while (!formatter.TryAppend(value, encoding)) { formatter.Enlarge(); } } - public static bool TryAppend(this TFormatter formatter, char value, EncodingData.Encoding encoding) where TFormatter : IOutput + public static bool TryAppend(this TFormatter formatter, char value, EncodingData.TextEncoding encoding) where TFormatter : IOutput { int bytesWritten; - if (!value.TryFormat(formatter.Buffer, encoding == EncodingData.Encoding.Utf8 ? EncodingData.InvariantUtf8 : EncodingData.InvariantUtf16, out bytesWritten)) { + if (!value.TryFormat(formatter.Buffer, encoding, out bytesWritten)) { return false; } formatter.Advance(bytesWritten); return true; } - public static void Append(this TFormatter formatter, Utf8String value, EncodingData.Encoding encoding) where TFormatter : IOutput + public static void Append(this TFormatter formatter, Utf8String value, EncodingData.TextEncoding encoding) where TFormatter : IOutput { while (!formatter.TryAppend(value, encoding)) { formatter.Enlarge(); } } - public static bool TryAppend(this TFormatter formatter, Utf8String value, EncodingData.Encoding encoding) where TFormatter : IOutput + public static bool TryAppend(this TFormatter formatter, Utf8String value, EncodingData.TextEncoding encoding) where TFormatter : IOutput { int bytesWritten; - if (!value.TryFormat(formatter.Buffer, encoding == EncodingData.Encoding.Utf8 ? EncodingData.InvariantUtf8 : EncodingData.InvariantUtf16, out bytesWritten)) { + if (!value.TryFormat(formatter.Buffer, encoding, out bytesWritten)) { return false; } formatter.Advance(bytesWritten); diff --git a/src/System.Text.Formatting/System/Text/Formatting/ITextOutputExtensions.cs b/src/System.Text.Formatting/System/Text/Formatting/ITextOutputExtensions.cs index 3cb9e65d8e0..1b94ac8db23 100644 --- a/src/System.Text.Formatting/System/Text/Formatting/ITextOutputExtensions.cs +++ b/src/System.Text.Formatting/System/Text/Formatting/ITextOutputExtensions.cs @@ -171,7 +171,7 @@ public static void Append(this TFormatter formatter, char value) whe public static bool TryAppend(this TFormatter formatter, char value) where TFormatter : ITextOutput { int bytesWritten; - if (!value.TryFormat(formatter.Buffer, formatter.Encoding, out bytesWritten)) { + if (!value.TryFormat(formatter.Buffer, formatter.Encoding.Encoding, out bytesWritten)) { return false; } formatter.Advance(bytesWritten); @@ -188,7 +188,7 @@ public static void Append(this TFormatter formatter, ReadOnlySpan(this TFormatter formatter, ReadOnlySpan value) where TFormatter : ITextOutput { int bytesWritten; - if (!value.TryFormat(formatter.Buffer, formatter.Encoding, out bytesWritten)) { + if (!value.TryFormat(formatter.Buffer, formatter.Encoding.Encoding, out bytesWritten)) { return false; } formatter.Advance(bytesWritten); @@ -220,7 +220,7 @@ public static void Append(this TFormatter formatter, string value) w public static bool TryAppend(this TFormatter formatter, string value) where TFormatter : ITextOutput { int bytesWritten; - if (!value.TryFormat(formatter.Buffer, formatter.Encoding, out bytesWritten)) { + if (!value.TryFormat(formatter.Buffer, formatter.Encoding.Encoding, out bytesWritten)) { return false; } formatter.Advance(bytesWritten); @@ -237,7 +237,7 @@ public static void Append(this TFormatter formatter, Utf8String valu public static bool TryAppend(this TFormatter formatter, Utf8String value) where TFormatter : ITextOutput { int bytesWritten; - if (!value.TryFormat(formatter.Buffer, formatter.Encoding, out bytesWritten)) { + if (!value.TryFormat(formatter.Buffer, formatter.Encoding.Encoding, out bytesWritten)) { return false; } formatter.Advance(bytesWritten); diff --git a/src/System.Text.Http/System/Text/Http/HttpHeaderBuffer.cs b/src/System.Text.Http/System/Text/Http/HttpHeaderBuffer.cs index 5c44a69cf33..900ba712b72 100644 --- a/src/System.Text.Http/System/Text/Http/HttpHeaderBuffer.cs +++ b/src/System.Text.Http/System/Text/Http/HttpHeaderBuffer.cs @@ -22,7 +22,7 @@ public void UpdateValue(string newValue) } int bytesWritten; - newValue.TryFormat(_bytes, _encoding, out bytesWritten); + newValue.TryFormat(_bytes, _encoding.Encoding, out bytesWritten); _bytes.SetFromRestOfSpanToEmpty(newValue.Length); } diff --git a/src/System.Text.Json.Dynamic/System/Text/Json/JsonDynamicObject.cs b/src/System.Text.Json.Dynamic/System/Text/Json/JsonDynamicObject.cs index a5121c62298..5e3c8d544bf 100644 --- a/src/System.Text.Json.Dynamic/System/Text/Json/JsonDynamicObject.cs +++ b/src/System.Text.Json.Dynamic/System/Text/Json/JsonDynamicObject.cs @@ -169,7 +169,7 @@ public bool TryFormat(Span buffer, Format.Parsed format, EncodingData form { written = 0; int justWritten; - if(!'{'.TryFormat(buffer, formattingData, out justWritten)){ + if(!'{'.TryFormat(buffer, formattingData.Encoding, out justWritten)){ return false; } written += justWritten; @@ -182,7 +182,7 @@ public bool TryFormat(Span buffer, Format.Parsed format, EncodingData form if(firstProperty) { firstProperty = false; } else { - if (!','.TryFormat(buffer.Slice(written), formattingData, out justWritten)) + if (!','.TryFormat(buffer.Slice(written), formattingData.Encoding, out justWritten)) { return false; } @@ -194,7 +194,7 @@ public bool TryFormat(Span buffer, Format.Parsed format, EncodingData form written = 0; return false; } written += justWritten; - if (!':'.TryFormat(buffer.Slice(written), formattingData, out justWritten)) + if (!':'.TryFormat(buffer.Slice(written), formattingData.Encoding, out justWritten)) { return false; } @@ -206,7 +206,7 @@ public bool TryFormat(Span buffer, Format.Parsed format, EncodingData form written += justWritten; } - if (!'}'.TryFormat(buffer.Slice(written), formattingData, out justWritten)){ + if (!'}'.TryFormat(buffer.Slice(written), formattingData.Encoding, out justWritten)){ written = 0; return false; } written += justWritten; @@ -268,11 +268,11 @@ public bool TryFormat(Span buffer, Format.Parsed format, EncodingData form case JsonReader.JsonValueType.Object: return _object.TryFormat(buffer, format, formattingData, out written); case JsonReader.JsonValueType.Null: - return "null".TryFormat(buffer, formattingData, out written); + return "null".TryFormat(buffer, formattingData.Encoding, out written); case JsonReader.JsonValueType.True: - return "true".TryFormat(buffer, formattingData, out written); + return "true".TryFormat(buffer, formattingData.Encoding, out written); case JsonReader.JsonValueType.False: - return "false".TryFormat(buffer, formattingData, out written); + return "false".TryFormat(buffer, formattingData.Encoding, out written); default: throw new NotImplementedException(); } @@ -348,7 +348,7 @@ public static bool TryFormatQuotedString(this Utf8String str, Span buffer, written = 0; int justWritten; - if (!'"'.TryFormat(buffer, formattingData, out justWritten)) + if (!'"'.TryFormat(buffer, formattingData.Encoding, out justWritten)) { return false; } @@ -360,7 +360,7 @@ public static bool TryFormatQuotedString(this Utf8String str, Span buffer, } written += justWritten; - if (!'"'.TryFormat(buffer.Slice(written), formattingData, out justWritten)) + if (!'"'.TryFormat(buffer.Slice(written), formattingData.Encoding, out justWritten)) { return false; } diff --git a/src/System.Text.Primitives/System/Text/EncodingData.cs b/src/System.Text.Primitives/System/Text/EncodingData.cs index e65735fc813..c57f5ab10ae 100644 --- a/src/System.Text.Primitives/System/Text/EncodingData.cs +++ b/src/System.Text.Primitives/System/Text/EncodingData.cs @@ -13,14 +13,16 @@ public struct EncodingData : IEquatable { private static EncodingData s_invariantUtf16; private static EncodingData s_invariantUtf8; + private byte[][] _digitsAndSymbols; // this could be flattened into a single array - private TrieNode[] _parsingTrie; - private Encoding _encoding; + private ParsingTrieNode[] _parsingTrie; + private TextEncoding _encoding; - public enum Encoding : byte + public enum TextEncoding : byte { Utf16 = 0, Utf8 = 1, + Ascii, } // The parsing trie is structured as an array, which means that there are two types of @@ -40,21 +42,21 @@ public enum Encoding : byte // The index is formatted as such: 0xAABBCCDD, where AA = the min value, // BB = the index of the min value relative to the current node (1-indexed), // CC = the max value, and DD = the max value's index in the same coord-system as BB. - public struct TrieNode + public struct ParsingTrieNode { public byte valueOrNumChildren; public int index; } // TODO: make these private once bin file generator is used - public EncodingData(byte[][] digitsAndSymbols, TrieNode[] parsingTrie, Encoding encoding) + public EncodingData(byte[][] digitsAndSymbols, TextEncoding encoding, ParsingTrieNode[] parsingTrie) { _digitsAndSymbols = digitsAndSymbols; _encoding = encoding; _parsingTrie = parsingTrie; } - public EncodingData(byte[][] digitsAndSymbols, Encoding encoding) + public EncodingData(byte[][] digitsAndSymbols, TextEncoding encoding) { _digitsAndSymbols = digitsAndSymbols; _encoding = encoding; @@ -128,7 +130,7 @@ static EncodingData() new byte[] { 101, 0, }, // e }; - s_invariantUtf16 = new EncodingData(utf16digitsAndSymbols, Encoding.Utf16); + s_invariantUtf16 = new EncodingData(utf16digitsAndSymbols, TextEncoding.Utf16); var utf8digitsAndSymbols = new byte[][] { new byte[] { 48, }, @@ -151,7 +153,7 @@ static EncodingData() new byte[] { 101, }, // e }; - s_invariantUtf8 = new EncodingData(utf8digitsAndSymbols, Encoding.Utf8); + s_invariantUtf8 = new EncodingData(utf8digitsAndSymbols, TextEncoding.Utf8); } public static EncodingData InvariantUtf16 @@ -348,14 +350,7 @@ public bool IsInvariantUtf8 get { return _digitsAndSymbols == s_invariantUtf8._digitsAndSymbols; } } - public bool IsUtf16 - { - get { return _encoding == Encoding.Utf16; } - } - public bool IsUtf8 - { - get { return _encoding == Encoding.Utf8; } - } + public TextEncoding Encoding => _encoding; public static bool operator==(EncodingData left, EncodingData right) { diff --git a/src/System.Text.Primitives/System/Text/Formatting/FloatFormatter.cs b/src/System.Text.Primitives/System/Text/Formatting/FloatFormatter.cs index d6860a8f738..63c39d7f490 100644 --- a/src/System.Text.Primitives/System/Text/Formatting/FloatFormatter.cs +++ b/src/System.Text.Primitives/System/Text/Formatting/FloatFormatter.cs @@ -44,7 +44,7 @@ public static bool TryFormatNumber(double value, bool isSingle, Span buffe // TODO: the lines below need to be replaced with properly implemented algorithm // the problem is the algorithm is complex, so I am commiting a stub for now var hack = value.ToString(format.Symbol.ToString()); - return hack.TryFormat(buffer, formattingData, out bytesWritten); + return hack.TryFormat(buffer, formattingData.Encoding, out bytesWritten); } } } diff --git a/src/System.Text.Primitives/System/Text/Formatting/IntegerFormatter.cs b/src/System.Text.Primitives/System/Text/Formatting/IntegerFormatter.cs index cf7d3900454..b415df4a295 100644 --- a/src/System.Text.Primitives/System/Text/Formatting/IntegerFormatter.cs +++ b/src/System.Text.Primitives/System/Text/Formatting/IntegerFormatter.cs @@ -64,11 +64,11 @@ internal static bool TryFormatUInt64(ulong value, byte numberOfBytes, Span format.Symbol = 'G'; } - if (format.IsHexadecimal && formattingData.IsUtf16) { + if (format.IsHexadecimal && formattingData.IsInvariantUtf16) { return TryFormatHexadecimalInvariantCultureUtf16(value, buffer, format, out bytesWritten); } - if (format.IsHexadecimal && formattingData.IsUtf8) { + if (format.IsHexadecimal && formattingData.IsInvariantUtf8) { return TryFormatHexadecimalInvariantCultureUtf8(value, buffer, format, out bytesWritten); } diff --git a/src/System.Text.Primitives/System/Text/Formatting/PrimitiveFormatter.cs b/src/System.Text.Primitives/System/Text/Formatting/PrimitiveFormatter.cs index 19a5d11f632..a78c3722513 100644 --- a/src/System.Text.Primitives/System/Text/Formatting/PrimitiveFormatter.cs +++ b/src/System.Text.Primitives/System/Text/Formatting/PrimitiveFormatter.cs @@ -53,9 +53,9 @@ public static bool TryFormat(this long value, Span buffer, Format.Parsed f } #endregion - public static bool TryFormat(this char value, Span buffer, EncodingData formattingData, out int bytesWritten) + public static bool TryFormat(this char value, Span buffer, EncodingData.TextEncoding encoding, out int bytesWritten) { - if (formattingData.IsUtf16) + if (encoding == EncodingData.TextEncoding.Utf16) { if (buffer.Length < 2) { @@ -68,49 +68,47 @@ public static bool TryFormat(this char value, Span buffer, EncodingData fo return true; } - if (buffer.Length < 1) - { - bytesWritten = 0; - return false; - } + if (encoding == EncodingData.TextEncoding.Utf8) { + if (buffer.Length < 1) { + bytesWritten = 0; + return false; + } - // fast path for ASCII - if (value <= 127) - { - buffer[0] = (byte)value; - bytesWritten = 1; - return true; - } + // fast path for ASCII + if (value <= 127) { + buffer[0] = (byte)value; + bytesWritten = 1; + return true; + } - // TODO: This can be directly encoded to SpanByte. There is no conversion between spans yet - var encoded = new Utf8EncodedCodePoint(value); - bytesWritten = encoded.Length; - if (buffer.Length < bytesWritten) - { - bytesWritten = 0; - return false; - } + // TODO: This can be directly encoded to SpanByte. There is no conversion between spans yet + var encoded = new Utf8EncodedCodePoint(value); + bytesWritten = encoded.Length; + if (buffer.Length < bytesWritten) { + bytesWritten = 0; + return false; + } - buffer[0] = encoded.Byte0; - if(bytesWritten > 1) - { - buffer[1] = encoded.Byte1; - } - if(bytesWritten > 2) - { - buffer[2] = encoded.Byte2; - } - if(bytesWritten > 3) - { - buffer[3] = encoded.Byte3; + buffer[0] = encoded.Byte0; + if (bytesWritten > 1) { + buffer[1] = encoded.Byte1; + } + if (bytesWritten > 2) { + buffer[2] = encoded.Byte2; + } + if (bytesWritten > 3) { + buffer[3] = encoded.Byte3; + } + return true; } - return true; + + throw new NotImplementedException(); } - public static bool TryFormat(this string value, Span buffer, EncodingData formattingData, out int bytesWritten) + public static bool TryFormat(this string value, Span buffer, EncodingData.TextEncoding encoding, out int bytesWritten) { - if (formattingData.IsUtf16) + if (encoding == EncodingData.TextEncoding.Utf16) { var valueBytes = value.Length << 1; if (valueBytes > buffer.Length) @@ -132,68 +130,64 @@ public static bool TryFormat(this string value, Span buffer, EncodingData return true; } - - var avaliableBytes = buffer.Length; - bytesWritten = 0; - for (int i = 0; i < value.Length; i++) - { - var c = value[i]; + if (encoding == EncodingData.TextEncoding.Utf8) { - var codepoint = (ushort)c; - if (codepoint <= 0x7f) // this if block just optimizes for ascii - { - if (bytesWritten + 1 > avaliableBytes) - { - bytesWritten = 0; - return false; - } - buffer[bytesWritten++] = (byte)codepoint; - } - else - { - Utf8EncodedCodePoint encoded; - if (!char.IsSurrogate(c)) - encoded = new Utf8EncodedCodePoint(c); - else - { - if (++i >= value.Length) - throw new ArgumentException("Invalid surrogate pair.", nameof(value)); - char lowSurrogate = value[i]; - encoded = new Utf8EncodedCodePoint(c, lowSurrogate); - } - + var avaliableBytes = buffer.Length; + bytesWritten = 0; + for (int i = 0; i < value.Length; i++) { + var c = value[i]; - if (bytesWritten + encoded.Length > avaliableBytes) + var codepoint = (ushort)c; + if (codepoint <= 0x7f) // this if block just optimizes for ascii { - bytesWritten = 0; - return false; + if (bytesWritten + 1 > avaliableBytes) { + bytesWritten = 0; + return false; + } + buffer[bytesWritten++] = (byte)codepoint; } + else { + Utf8EncodedCodePoint encoded; + if (!char.IsSurrogate(c)) + encoded = new Utf8EncodedCodePoint(c); + else { + if (++i >= value.Length) + throw new ArgumentException("Invalid surrogate pair.", nameof(value)); + char lowSurrogate = value[i]; + encoded = new Utf8EncodedCodePoint(c, lowSurrogate); + } - buffer[bytesWritten] = encoded.Byte0; - if (encoded.Length > 1) - { - buffer[bytesWritten + 1] = encoded.Byte1; - if (encoded.Length > 2) - { - buffer[bytesWritten + 2] = encoded.Byte2; + if (bytesWritten + encoded.Length > avaliableBytes) { + bytesWritten = 0; + return false; + } - if (encoded.Length > 3) - { - buffer[bytesWritten + 3] = encoded.Byte3; + buffer[bytesWritten] = encoded.Byte0; + if (encoded.Length > 1) { + buffer[bytesWritten + 1] = encoded.Byte1; + + if (encoded.Length > 2) { + buffer[bytesWritten + 2] = encoded.Byte2; + + if (encoded.Length > 3) { + buffer[bytesWritten + 3] = encoded.Byte3; + } } } - } - bytesWritten += encoded.Length; + bytesWritten += encoded.Length; + } } + return true; } - return true; + + throw new NotImplementedException(); } - public static bool TryFormat(this Utf8String value, Span buffer, EncodingData formattingData, out int bytesWritten) + public static bool TryFormat(this Utf8String value, Span buffer, EncodingData.TextEncoding encoding, out int bytesWritten) { - if (formattingData.IsUtf16) { + if (encoding == EncodingData.TextEncoding.Utf16) { bytesWritten = 0; int justWritten; foreach(var cp in value.CodePoints) { @@ -206,19 +200,23 @@ public static bool TryFormat(this Utf8String value, Span buffer, EncodingD return true; } - if(buffer.Length < value.Length) { - bytesWritten = 0; - return false; + if (encoding == EncodingData.TextEncoding.Utf8) { + if (buffer.Length < value.Length) { + bytesWritten = 0; + return false; + } + + buffer.Set(value.Bytes); + bytesWritten = value.Length; + return true; } - buffer.Set(value.Bytes); - bytesWritten = value.Length; - return true; + throw new NotImplementedException(); } - public static bool TryFormat(this ReadOnlySpan value, Span buffer, EncodingData formattingData, out int bytesWritten) + public static bool TryFormat(this ReadOnlySpan value, Span buffer, EncodingData.TextEncoding encoding, out int bytesWritten) { - if (formattingData.IsUtf16) { + if (encoding == EncodingData.TextEncoding.Utf16) { var valueBytes = value.Cast(); if (buffer.Length < valueBytes.Length) { bytesWritten = 0; @@ -229,7 +227,7 @@ public static bool TryFormat(this ReadOnlySpan value, Span buffer, E return true; } - if (formattingData.IsUtf8) { + if (encoding == EncodingData.TextEncoding.Utf8) { var avaliableBytes = buffer.Length; bytesWritten = 0; for (int i = 0; i < value.Length; i++) { diff --git a/src/System.Text.Primitives/System/Text/Formatting/PrimitiveFormatter_time.cs b/src/System.Text.Primitives/System/Text/Formatting/PrimitiveFormatter_time.cs index 643908addf8..e4d46f4800d 100644 --- a/src/System.Text.Primitives/System/Text/Formatting/PrimitiveFormatter_time.cs +++ b/src/System.Text.Primitives/System/Text/Formatting/PrimitiveFormatter_time.cs @@ -36,7 +36,7 @@ public static bool TryFormat(this DateTimeOffset value, Span buffer, Forma { case 'R': - if (formattingData.IsUtf16) + if (formattingData.IsInvariantUtf16) // TODO: there are many checks like this one in the code. They need to also verify that the UTF8 branch is invariant. { return TryFormatDateTimeRfc1123(value.UtcDateTime, buffer, EncodingData.InvariantUtf16, out bytesWritten); } @@ -45,7 +45,7 @@ public static bool TryFormat(this DateTimeOffset value, Span buffer, Forma return TryFormatDateTimeRfc1123(value.UtcDateTime, buffer, EncodingData.InvariantUtf8, out bytesWritten); } case 'O': - if (formattingData.IsUtf16) + if (formattingData.IsInvariantUtf16) { return TryFormatDateTimeFormatO(value.UtcDateTime, false, buffer, EncodingData.InvariantUtf16, out bytesWritten); } @@ -78,7 +78,7 @@ public static bool TryFormat(this DateTime value, Span buffer, Format.Pars { case 'R': var utc = value.ToUniversalTime(); - if (formattingData.IsUtf16) + if (formattingData.IsInvariantUtf16) { return TryFormatDateTimeRfc1123(utc, buffer, EncodingData.InvariantUtf16, out bytesWritten); } @@ -87,7 +87,7 @@ public static bool TryFormat(this DateTime value, Span buffer, Format.Pars return TryFormatDateTimeRfc1123(utc, buffer, EncodingData.InvariantUtf8, out bytesWritten); } case 'O': - if (formattingData.IsUtf16) + if (formattingData.IsInvariantUtf16) { return TryFormatDateTimeFormatO(value, true, buffer, EncodingData.InvariantUtf16, out bytesWritten); } @@ -112,13 +112,13 @@ static bool TryFormatDateTimeFormagG(DateTime value, Span buffer, Encoding bytesWritten = 0; if (!TryWriteInt32(value.Month, buffer, G, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar('/', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('/', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } if (!TryWriteInt32(value.Day, buffer, G, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar('/', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('/', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } if (!TryWriteInt32(value.Year, buffer, G, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(' ', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar(' ', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } var hour = value.Hour; if(hour == 0) @@ -131,21 +131,21 @@ static bool TryFormatDateTimeFormagG(DateTime value, Span buffer, Encoding } if (!TryWriteInt32(hour, buffer, G, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(':', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar(':', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } if (!TryWriteInt32(value.Minute, buffer, D2, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(':', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar(':', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } if (!TryWriteInt32(value.Second, buffer, D2, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(' ', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar(' ', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } if(value.Hour > 11) { - TryWriteString("PM", buffer, formattingData, ref bytesWritten); + TryWriteString("PM", buffer, formattingData.Encoding, ref bytesWritten); } else { - TryWriteString("AM", buffer, formattingData, ref bytesWritten); + TryWriteString("AM", buffer, formattingData.Encoding, ref bytesWritten); } return true; @@ -155,19 +155,19 @@ static bool TryFormatDateTimeFormatO(DateTimeOffset value, bool isDateTime, Span { bytesWritten = 0; if (!TryWriteInt32(value.Year, buffer, D4, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar('-', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('-', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } if (!TryWriteInt32(value.Month, buffer, D2, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar('-', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('-', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } if (!TryWriteInt32(value.Day, buffer, D2, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar('T', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('T', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } if (!TryWriteInt32(value.Hour, buffer, D2, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(':', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar(':', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } if (!TryWriteInt32(value.Minute, buffer, D2, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(':', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar(':', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } if (!TryWriteInt32(value.Second, buffer, D2, formattingData, ref bytesWritten)) { return false; } @@ -177,18 +177,18 @@ static bool TryFormatDateTimeFormatO(DateTimeOffset value, bool isDateTime, Span if (delta.Ticks != 0) { - if (!TryWriteChar('.', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('.', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } var timeFrac = delta.Ticks * FractionalTimeScale / System.TimeSpan.TicksPerSecond; if (!TryWriteInt64(timeFrac, buffer, D7, formattingData, ref bytesWritten)) { return false; } } if (isDateTime) { - if (!TryWriteChar('Z', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('Z', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } } else { - if (!TryWriteChar('+', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('+', buffer, formattingData.Encoding, ref bytesWritten)) { return false; } int bytes; if (!value.Offset.TryFormat(buffer.Slice(bytesWritten), t, formattingData, out bytes)) { return false; } bytesWritten += bytes; @@ -197,32 +197,32 @@ static bool TryFormatDateTimeFormatO(DateTimeOffset value, bool isDateTime, Span return true; } - static bool TryFormatDateTimeRfc1123(DateTime value, Span buffer, EncodingData formattingData, out int bytesWritten) + static bool TryFormatDateTimeRfc1123(DateTime value, Span buffer, EncodingData encoding, out int bytesWritten) { bytesWritten = 0; - if (!TryWriteString(s_dayNames[(int)value.DayOfWeek], buffer, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteInt32(value.Day, buffer, D2, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(' ', buffer, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteString(s_monthNames[value.Month - 1], buffer, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(' ', buffer, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteInt32(value.Year, buffer, D4, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(' ', buffer, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteInt32(value.Hour, buffer, D2, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(':', buffer, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteInt32(value.Minute, buffer, D2, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(':', buffer, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteInt32(value.Second, buffer, D2, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteString(" GMT", buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteString(s_dayNames[(int)value.DayOfWeek], buffer, encoding.Encoding, ref bytesWritten)) { return false; } + if (!TryWriteInt32(value.Day, buffer, D2, encoding, ref bytesWritten)) { return false; } + if (!TryWriteChar(' ', buffer, encoding.Encoding, ref bytesWritten)) { return false; } + if (!TryWriteString(s_monthNames[value.Month - 1], buffer, encoding.Encoding, ref bytesWritten)) { return false; } + if (!TryWriteChar(' ', buffer, encoding.Encoding, ref bytesWritten)) { return false; } + if (!TryWriteInt32(value.Year, buffer, D4, encoding, ref bytesWritten)) { return false; } + if (!TryWriteChar(' ', buffer, encoding.Encoding, ref bytesWritten)) { return false; } + if (!TryWriteInt32(value.Hour, buffer, D2, encoding, ref bytesWritten)) { return false; } + if (!TryWriteChar(':', buffer, encoding.Encoding, ref bytesWritten)) { return false; } + if (!TryWriteInt32(value.Minute, buffer, D2, encoding, ref bytesWritten)) { return false; } + if (!TryWriteChar(':', buffer, encoding.Encoding, ref bytesWritten)) { return false; } + if (!TryWriteInt32(value.Second, buffer, D2, encoding, ref bytesWritten)) { return false; } + if (!TryWriteString(" GMT", buffer, encoding.Encoding, ref bytesWritten)) { return false; } return true; } - public static bool TryFormat(this TimeSpan value, Span buffer, ReadOnlySpan format, EncodingData formattingData, out int bytesWritten) + public static bool TryFormat(this TimeSpan value, Span buffer, ReadOnlySpan format, EncodingData encoding, out int bytesWritten) { Format.Parsed parsedFormat = Format.Parse(format); - return TryFormat(value, buffer, parsedFormat, formattingData, out bytesWritten); + return TryFormat(value, buffer, parsedFormat, encoding, out bytesWritten); } - public static bool TryFormat(this TimeSpan value, Span buffer, Format.Parsed format, EncodingData formattingData, out int bytesWritten) + public static bool TryFormat(this TimeSpan value, Span buffer, Format.Parsed format, EncodingData encoding, out int bytesWritten) { if (format.IsDefault) { @@ -232,34 +232,34 @@ public static bool TryFormat(this TimeSpan value, Span buffer, Format.Pars if (format.Symbol != 't') { - return TryFormatTimeSpanG(value, buffer, format, formattingData, out bytesWritten); + return TryFormatTimeSpanG(value, buffer, format, encoding, out bytesWritten); } // else it's format 't' (short time used to print time offsets) - return TryFormatTimeSpanT(value, buffer, formattingData, out bytesWritten); + return TryFormatTimeSpanT(value, buffer, encoding, out bytesWritten); } - private static bool TryFormatTimeSpanG(TimeSpan value, Span buffer, Format.Parsed format, EncodingData formattingData, out int bytesWritten) + private static bool TryFormatTimeSpanG(TimeSpan value, Span buffer, Format.Parsed format, EncodingData encoding, out int bytesWritten) { bytesWritten = 0; if (value.Ticks < 0) { - if (!TryWriteChar('-', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('-', buffer, encoding.Encoding, ref bytesWritten)) { return false; } } bool daysWritten = false; if (value.Days != 0 || format.Symbol == 'G') { - if (!TryWriteInt32(Abs(value.Days), buffer, default(Format.Parsed), formattingData, ref bytesWritten)) { return false; } + if (!TryWriteInt32(Abs(value.Days), buffer, default(Format.Parsed), encoding, ref bytesWritten)) { return false; } daysWritten = true; if (format.Symbol == 'c') { - if (!TryWriteChar('.', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('.', buffer, encoding.Encoding, ref bytesWritten)) { return false; } } else { - if (!TryWriteChar(':', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar(':', buffer, encoding.Encoding, ref bytesWritten)) { return false; } } } @@ -268,13 +268,13 @@ private static bool TryFormatTimeSpanG(TimeSpan value, Span buffer, Format { hourFormat = D2; } - if (!TryWriteInt32(Abs(value.Hours), buffer, hourFormat, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(':', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteInt32(Abs(value.Hours), buffer, hourFormat, encoding, ref bytesWritten)) { return false; } + if (!TryWriteChar(':', buffer, encoding.Encoding, ref bytesWritten)) { return false; } - if (!TryWriteInt32(Abs(value.Minutes), buffer, D2, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(':', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteInt32(Abs(value.Minutes), buffer, D2, encoding, ref bytesWritten)) { return false; } + if (!TryWriteChar(':', buffer, encoding.Encoding, ref bytesWritten)) { return false; } - if (!TryWriteInt32(Abs(value.Seconds), buffer, D2, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteInt32(Abs(value.Seconds), buffer, D2, encoding, ref bytesWritten)) { return false; } long remainingTicks; if (value.Ticks != long.MinValue) @@ -290,27 +290,27 @@ private static bool TryFormatTimeSpanG(TimeSpan value, Span buffer, Format var ticksFormat = D7; if (remainingTicks != 0) { - if (!TryWriteChar('.', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('.', buffer, encoding.Encoding, ref bytesWritten)) { return false; } var fraction = remainingTicks * FractionalTimeScale / TimeSpan.TicksPerSecond; - if (!TryWriteInt64(fraction, buffer, ticksFormat, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteInt64(fraction, buffer, ticksFormat, encoding, ref bytesWritten)) { return false; } } return true; } - private static bool TryFormatTimeSpanT(TimeSpan value, Span buffer, EncodingData formattingData, out int bytesWritten) + private static bool TryFormatTimeSpanT(TimeSpan value, Span buffer, EncodingData encoding, out int bytesWritten) { bytesWritten = 0; if (value.Ticks < 0) { - if (!TryWriteChar('-', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('-', buffer, encoding.Encoding, ref bytesWritten)) { return false; } } - if (!TryWriteInt32(Abs((int)value.TotalHours), buffer, D2, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteChar(':', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteInt32(Abs((int)value.TotalHours), buffer, D2, encoding, ref bytesWritten)) { return false; } + if (!TryWriteChar(':', buffer, encoding.Encoding, ref bytesWritten)) { return false; } - if (!TryWriteInt32(Abs(value.Minutes), buffer, D2, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteInt32(Abs(value.Minutes), buffer, D2, encoding, ref bytesWritten)) { return false; } return true; } diff --git a/src/System.Text.Primitives/System/Text/Formatting/PrimitiveFormatter_uuid.cs b/src/System.Text.Primitives/System/Text/Formatting/PrimitiveFormatter_uuid.cs index 8584c4a4fd3..1ff22c2dacf 100644 --- a/src/System.Text.Primitives/System/Text/Formatting/PrimitiveFormatter_uuid.cs +++ b/src/System.Text.Primitives/System/Text/Formatting/PrimitiveFormatter_uuid.cs @@ -15,7 +15,7 @@ public static bool TryFormat(this Guid value, Span buffer, ReadOnlySpan buffer, Format.Parsed format, EncodingData formattingData, out int bytesWritten) + public static bool TryFormat(this Guid value, Span buffer, Format.Parsed format, EncodingData encoding, out int bytesWritten) { if (format.IsDefault) { @@ -37,12 +37,12 @@ public static bool TryFormat(this Guid value, Span buffer, Format.Parsed f break; case 'B': - if (!TryWriteChar('{', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('{', buffer, encoding.Encoding, ref bytesWritten)) { return false; } tail = '}'; break; case 'P': - if (!TryWriteChar('(', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('(', buffer, encoding.Encoding, ref bytesWritten)) { return false; } tail = ')'; break; @@ -57,51 +57,51 @@ public static bool TryFormat(this Guid value, Span buffer, Format.Parsed f { byte* bytes = (byte*)&value; - if (!TryWriteByte(bytes[3], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteByte(bytes[2], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteByte(bytes[1], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteByte(bytes[0], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[3], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[2], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[1], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[0], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } if (dash) { - if (!TryWriteChar('-', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('-', buffer, encoding.Encoding, ref bytesWritten)) { return false; } } - if (!TryWriteByte(bytes[5], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteByte(bytes[4], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[5], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[4], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } if (dash) { - if (!TryWriteChar('-', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('-', buffer, encoding.Encoding, ref bytesWritten)) { return false; } } - if (!TryWriteByte(bytes[7], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteByte(bytes[6], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[7], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[6], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } if (dash) { - if (!TryWriteChar('-', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('-', buffer, encoding.Encoding, ref bytesWritten)) { return false; } } - if (!TryWriteByte(bytes[8], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteByte(bytes[9], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[8], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[9], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } if (dash) { - if (!TryWriteChar('-', buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar('-', buffer, encoding.Encoding, ref bytesWritten)) { return false; } } - if (!TryWriteByte(bytes[10], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteByte(bytes[11], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteByte(bytes[12], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteByte(bytes[13], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteByte(bytes[14], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } - if (!TryWriteByte(bytes[15], buffer, byteFormat, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[10], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[11], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[12], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[13], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[14], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } + if (!TryWriteByte(bytes[15], buffer, byteFormat, encoding, ref bytesWritten)) { return false; } } if (tail != '\0') { - if (!TryWriteChar(tail, buffer, formattingData, ref bytesWritten)) { return false; } + if (!TryWriteChar(tail, buffer, encoding.Encoding, ref bytesWritten)) { return false; } } return true; @@ -149,10 +149,10 @@ static bool TryWriteInt64(long i, Span buffer, Format.Parsed byteFormat, E } [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool TryWriteChar(char c, Span buffer, EncodingData formattingData, ref int bytesWritten) + static bool TryWriteChar(char c, Span buffer, EncodingData.TextEncoding encoding, ref int bytesWritten) { int written; - if (!c.TryFormat(buffer.Slice(bytesWritten), formattingData, out written)) + if (!c.TryFormat(buffer.Slice(bytesWritten), encoding, out written)) { bytesWritten = 0; return false; @@ -162,10 +162,10 @@ static bool TryWriteChar(char c, Span buffer, EncodingData formattingData, } [MethodImpl(MethodImplOptions.AggressiveInlining)] - static bool TryWriteString(string s, Span buffer, EncodingData formattingData, ref int bytesWritten) + static bool TryWriteString(string s, Span buffer, EncodingData.TextEncoding encoding, ref int bytesWritten) { int written; - if (!s.TryFormat(buffer.Slice(bytesWritten), formattingData, out written)) + if (!s.TryFormat(buffer.Slice(bytesWritten), encoding, out written)) { bytesWritten = 0; return false; diff --git a/src/System.Text.Primitives/System/Text/Parsing/PrimitiveParser_uint.cs b/src/System.Text.Primitives/System/Text/Parsing/PrimitiveParser_uint.cs index bd75f9f340e..7caf0b206bc 100644 --- a/src/System.Text.Primitives/System/Text/Parsing/PrimitiveParser_uint.cs +++ b/src/System.Text.Primitives/System/Text/Parsing/PrimitiveParser_uint.cs @@ -20,7 +20,7 @@ public static bool TryParseUInt32(string text, int index, int count, out uint va char* pSubstring = pText + index; var span = new Span((byte*)pSubstring, count << 1); int bytesConsumed; - var result = TryParseUInt32(span, EncodingData.Encoding.Utf16, out value, out bytesConsumed); + var result = TryParseUInt32(span, EncodingData.TextEncoding.Utf16, out value, out bytesConsumed); charactersConsumed = bytesConsumed >> 1; return result; } @@ -33,7 +33,7 @@ public static bool TryParseUInt32(ReadOnlySpan text, out uint value, out i ReadOnlySpan span = text.Cast(); int bytesConsumed; - var result = TryParseUInt32(span, EncodingData.Encoding.Utf16, out value, out bytesConsumed); + var result = TryParseUInt32(span, EncodingData.TextEncoding.Utf16, out value, out bytesConsumed); charactersConsumed = bytesConsumed >> 1; return result; } @@ -86,17 +86,17 @@ public static bool TryParseUInt32(Utf8String text, out uint value, out int bytes return true; } - public static bool TryParseUInt32(ReadOnlySpan text, EncodingData.Encoding encoding, out uint value, out int bytesConsumed) + public static bool TryParseUInt32(ReadOnlySpan text, EncodingData.TextEncoding encoding, out uint value, out int bytesConsumed) { Precondition.Require(text.Length > 0); - Precondition.Require(encoding == EncodingData.Encoding.Utf8 || text.Length > 1); + Precondition.Require(encoding == EncodingData.TextEncoding.Utf8 || text.Length > 1); value = 0; bytesConsumed = 0; if (text[0] == '0') { - if (encoding == EncodingData.Encoding.Utf16) + if (encoding == EncodingData.TextEncoding.Utf16) { bytesConsumed = 2; return text[1] == 0; @@ -131,7 +131,7 @@ public static bool TryParseUInt32(ReadOnlySpan text, EncodingData.Encoding return true; } bytesConsumed++; - if (encoding == EncodingData.Encoding.Utf16) + if (encoding == EncodingData.TextEncoding.Utf16) { byteIndex++; if (byteIndex >= text.Length || text[byteIndex] != 0) diff --git a/tests/System.Text.Formatting.Tests/CustomCulture.cs b/tests/System.Text.Formatting.Tests/CustomCulture.cs index f6f0bae5088..6b7cc7571b5 100644 --- a/tests/System.Text.Formatting.Tests/CustomCulture.cs +++ b/tests/System.Text.Formatting.Tests/CustomCulture.cs @@ -26,7 +26,7 @@ static CustomCultureTests() utf16digitsAndSymbols[(ushort)EncodingData.Symbol.DecimalSeparator] = GetBytesUtf16("."); utf16digitsAndSymbols[(ushort)EncodingData.Symbol.GroupSeparator] = GetBytesUtf16(","); utf16digitsAndSymbols[(ushort)EncodingData.Symbol.MinusSign] = GetBytesUtf16("_?"); - Culture5 = new EncodingData(utf16digitsAndSymbols, EncodingData.Encoding.Utf16); + Culture5 = new EncodingData(utf16digitsAndSymbols, EncodingData.TextEncoding.Utf16); utf16digitsAndSymbols = new byte[17][]; for (ushort digit = 0; digit < 10; digit++) @@ -38,7 +38,7 @@ static CustomCultureTests() utf16digitsAndSymbols[(ushort)EncodingData.Symbol.DecimalSeparator] = GetBytesUtf16("."); utf16digitsAndSymbols[(ushort)EncodingData.Symbol.GroupSeparator] = GetBytesUtf16(","); utf16digitsAndSymbols[(ushort)EncodingData.Symbol.MinusSign] = GetBytesUtf16("_?"); - Culture1 = new EncodingData(utf16digitsAndSymbols, EncodingData.Encoding.Utf16); + Culture1 = new EncodingData(utf16digitsAndSymbols, EncodingData.TextEncoding.Utf16); } private static byte[] GetBytesUtf16(string text) diff --git a/tests/System.Text.Formatting.Tests/CustomTypeFormatting.cs b/tests/System.Text.Formatting.Tests/CustomTypeFormatting.cs index bca2e9adc84..514aaf6284e 100644 --- a/tests/System.Text.Formatting.Tests/CustomTypeFormatting.cs +++ b/tests/System.Text.Formatting.Tests/CustomTypeFormatting.cs @@ -26,7 +26,7 @@ public bool TryFormat(Span buffer, Format.Parsed format, EncodingData enco char symbol = _inMonths ? 'm' : 'y'; int symbolBytes; - if (!PrimitiveFormatter.TryFormat(symbol, buffer.Slice(bytesWritten), encoding, out symbolBytes)) return false; + if (!PrimitiveFormatter.TryFormat(symbol, buffer.Slice(bytesWritten), encoding.Encoding, out symbolBytes)) return false; bytesWritten += symbolBytes; return true; diff --git a/tests/System.Text.Formatting.Tests/PerformanceTests.cs b/tests/System.Text.Formatting.Tests/PerformanceTests.cs index b5eb4e439a6..b4ce75f0a12 100644 --- a/tests/System.Text.Formatting.Tests/PerformanceTests.cs +++ b/tests/System.Text.Formatting.Tests/PerformanceTests.cs @@ -272,7 +272,7 @@ static EncodingData CreateCustomCulture() utf16digitsAndSymbols[(ushort)EncodingData.Symbol.DecimalSeparator] = GetBytesUtf16("."); utf16digitsAndSymbols[(ushort)EncodingData.Symbol.GroupSeparator] = GetBytesUtf16(","); utf16digitsAndSymbols[(ushort)EncodingData.Symbol.MinusSign] = GetBytesUtf16("_?"); - return new EncodingData(utf16digitsAndSymbols, EncodingData.Encoding.Utf16); + return new EncodingData(utf16digitsAndSymbols, EncodingData.TextEncoding.Utf16); } static byte[] GetBytesUtf16(string text) { diff --git a/tests/System.Text.Primitives.Tests/ParserTests.cs b/tests/System.Text.Primitives.Tests/ParserTests.cs index e07a233c8a6..c168addf49d 100644 --- a/tests/System.Text.Primitives.Tests/ParserTests.cs +++ b/tests/System.Text.Primitives.Tests/ParserTests.cs @@ -52,46 +52,46 @@ public unsafe void ParseCustomCultureByteArrayToByte(string text, bool expectSuc new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.TrieNode[] + var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] { - new EncodingData.TrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.TrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.TrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.TrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.TrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.TrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.TrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.TrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.TrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.TrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, }; - EncodingData fd = new EncodingData(utf8digitsAndSymbols, utf8ParsingTrie, EncodingData.Encoding.Utf8); + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseByte(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -280,46 +280,46 @@ public unsafe void ParseCustomCultureByteArrayToUshort(string text, bool expectS new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.TrieNode[] + var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] { - new EncodingData.TrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.TrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.TrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.TrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.TrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.TrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.TrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.TrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.TrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.TrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, }; - EncodingData fd = new EncodingData(utf8digitsAndSymbols, utf8ParsingTrie, EncodingData.Encoding.Utf8); + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseUInt16(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -508,46 +508,46 @@ public unsafe void ParseCustomCultureByteArrayToUint(string text, bool expectSuc new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.TrieNode[] + var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] { - new EncodingData.TrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.TrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.TrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.TrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.TrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.TrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.TrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.TrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.TrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.TrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, }; - EncodingData fd = new EncodingData(utf8digitsAndSymbols, utf8ParsingTrie, EncodingData.Encoding.Utf8); + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseUInt32(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -736,46 +736,46 @@ public unsafe void ParseCustomCultureByteArrayToUlong(string text, bool expectSu new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.TrieNode[] + var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] { - new EncodingData.TrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.TrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.TrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.TrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.TrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.TrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.TrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.TrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.TrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.TrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, }; - EncodingData fd = new EncodingData(utf8digitsAndSymbols, utf8ParsingTrie, EncodingData.Encoding.Utf8); + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseUInt64(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -968,46 +968,46 @@ public unsafe void ParseCustomCultureByteArrayToSbyte(string text, bool expectSu new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.TrieNode[] + var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] { - new EncodingData.TrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.TrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.TrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.TrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.TrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.TrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.TrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.TrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.TrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.TrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, }; - EncodingData fd = new EncodingData(utf8digitsAndSymbols, utf8ParsingTrie, EncodingData.Encoding.Utf8); + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseSByte(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -1044,51 +1044,51 @@ public unsafe void ParseCustomCultureThaiByteArrayToSbyte(string text, bool expe 0x83, 0xE0, 0xB8, 0x8A, 0xE0, 0xB9, 0x88, 0xE0, 0xB8, 0x95, 0xE0, 0xB8, 0xB1, 0xE0, 0xB8, 0xA7, 0xE0, 0xB9, 0x80, 0xE0, 0xB8, 0xA5, 0xE0, 0xB8, 0x82 }, new byte[] { 69 }, new byte[] { 101 }, }; - var thaiUtf8ParsingTrie = new EncodingData.TrieNode[] + var thaiUtf8ParsingTrie = new EncodingData.ParsingTrieNode[] { - new EncodingData.TrieNode { valueOrNumChildren = 4, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xE0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 2, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xB8, index = 11 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xB9, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 3, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x88, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xA5, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xAA, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 11, index = -1878877941 /* 0x9002990B */ }, - new EncodingData.TrieNode { valueOrNumChildren = 0x84, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x90, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x91, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x92, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x93, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x94, index = 35 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x95, index = 36 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x96, index = 37 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x97, index = 38 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x98, index = 39 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x99, index = 40 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 4, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xE0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 2, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB8, index = 11 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB9, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 3, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x88, index = 27 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xA5, index = 28 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xAA, index = 29 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 11, index = -1878877941 /* 0x9002990B */ }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x84, index = 30 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x90, index = 31 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x91, index = 32 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x92, index = 33 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x93, index = 34 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x94, index = 35 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x95, index = 36 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x96, index = 37 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x97, index = 38 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x98, index = 39 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x99, index = 40 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, }; - EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, thaiUtf8ParsingTrie, EncodingData.Encoding.Utf8); + EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, EncodingData.TextEncoding.Utf8, thaiUtf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseSByte(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -1307,46 +1307,46 @@ public unsafe void ParseCustomCultureByteArrayToShort(string text, bool expectSu new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.TrieNode[] + var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] { - new EncodingData.TrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.TrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.TrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.TrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.TrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.TrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.TrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.TrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.TrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.TrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, }; - EncodingData fd = new EncodingData(utf8digitsAndSymbols, utf8ParsingTrie, EncodingData.Encoding.Utf8); + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseInt16(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -1383,51 +1383,51 @@ public unsafe void ParseCustomCultureThaiByteArrayToShort(string text, bool expe 0x83, 0xE0, 0xB8, 0x8A, 0xE0, 0xB9, 0x88, 0xE0, 0xB8, 0x95, 0xE0, 0xB8, 0xB1, 0xE0, 0xB8, 0xA7, 0xE0, 0xB9, 0x80, 0xE0, 0xB8, 0xA5, 0xE0, 0xB8, 0x82 }, new byte[] { 69 }, new byte[] { 101 }, }; - var thaiUtf8ParsingTrie = new EncodingData.TrieNode[] + var thaiUtf8ParsingTrie = new EncodingData.ParsingTrieNode[] { - new EncodingData.TrieNode { valueOrNumChildren = 4, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xE0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 2, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xB8, index = 11 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xB9, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 3, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x88, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xA5, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xAA, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 11, index = -1878877941 /* 0x9002990B */ }, - new EncodingData.TrieNode { valueOrNumChildren = 0x84, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x90, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x91, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x92, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x93, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x94, index = 35 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x95, index = 36 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x96, index = 37 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x97, index = 38 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x98, index = 39 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x99, index = 40 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 4, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xE0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 2, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB8, index = 11 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB9, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 3, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x88, index = 27 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xA5, index = 28 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xAA, index = 29 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 11, index = -1878877941 /* 0x9002990B */ }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x84, index = 30 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x90, index = 31 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x91, index = 32 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x92, index = 33 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x93, index = 34 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x94, index = 35 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x95, index = 36 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x96, index = 37 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x97, index = 38 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x98, index = 39 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x99, index = 40 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, }; - EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, thaiUtf8ParsingTrie, EncodingData.Encoding.Utf8); + EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, EncodingData.TextEncoding.Utf8, thaiUtf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseInt16(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -1646,46 +1646,46 @@ public unsafe void ParseCustomCultureByteArrayToInt(string text, bool expectSucc new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.TrieNode[] + var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] { - new EncodingData.TrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.TrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.TrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.TrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.TrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.TrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.TrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.TrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.TrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.TrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, }; - EncodingData fd = new EncodingData(utf8digitsAndSymbols, utf8ParsingTrie, EncodingData.Encoding.Utf8); + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseInt32(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -1722,51 +1722,51 @@ public unsafe void ParseCustomCultureThaiByteArrayToInt(string text, bool expect 0x83, 0xE0, 0xB8, 0x8A, 0xE0, 0xB9, 0x88, 0xE0, 0xB8, 0x95, 0xE0, 0xB8, 0xB1, 0xE0, 0xB8, 0xA7, 0xE0, 0xB9, 0x80, 0xE0, 0xB8, 0xA5, 0xE0, 0xB8, 0x82 }, new byte[] { 69 }, new byte[] { 101 }, }; - var thaiUtf8ParsingTrie = new EncodingData.TrieNode[] + var thaiUtf8ParsingTrie = new EncodingData.ParsingTrieNode[] { - new EncodingData.TrieNode { valueOrNumChildren = 4, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xE0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 2, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xB8, index = 11 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xB9, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 3, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x88, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xA5, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xAA, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 11, index = -1878877941 /* 0x9002990B */ }, - new EncodingData.TrieNode { valueOrNumChildren = 0x84, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x90, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x91, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x92, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x93, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x94, index = 35 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x95, index = 36 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x96, index = 37 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x97, index = 38 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x98, index = 39 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x99, index = 40 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 4, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xE0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 2, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB8, index = 11 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB9, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 3, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x88, index = 27 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xA5, index = 28 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xAA, index = 29 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 11, index = -1878877941 /* 0x9002990B */ }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x84, index = 30 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x90, index = 31 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x91, index = 32 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x92, index = 33 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x93, index = 34 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x94, index = 35 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x95, index = 36 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x96, index = 37 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x97, index = 38 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x98, index = 39 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x99, index = 40 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, }; - EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, thaiUtf8ParsingTrie, EncodingData.Encoding.Utf8); + EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, EncodingData.TextEncoding.Utf8, thaiUtf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseInt32(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -1985,46 +1985,46 @@ public unsafe void ParseCustomCultureByteArrayToLong(string text, bool expectSuc new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.TrieNode[] + var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] { - new EncodingData.TrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.TrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.TrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.TrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.TrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.TrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.TrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.TrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.TrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.TrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, }; - EncodingData fd = new EncodingData(utf8digitsAndSymbols, utf8ParsingTrie, EncodingData.Encoding.Utf8); + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseInt64(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -2061,51 +2061,51 @@ public unsafe void ParseCustomCultureThaiByteArrayToLong(string text, bool expec 0x83, 0xE0, 0xB8, 0x8A, 0xE0, 0xB9, 0x88, 0xE0, 0xB8, 0x95, 0xE0, 0xB8, 0xB1, 0xE0, 0xB8, 0xA7, 0xE0, 0xB9, 0x80, 0xE0, 0xB8, 0xA5, 0xE0, 0xB8, 0x82 }, new byte[] { 69 }, new byte[] { 101 }, }; - var thaiUtf8ParsingTrie = new EncodingData.TrieNode[] + var thaiUtf8ParsingTrie = new EncodingData.ParsingTrieNode[] { - new EncodingData.TrieNode { valueOrNumChildren = 4, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xE0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 2, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xB8, index = 11 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xB9, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 3, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x88, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xA5, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xAA, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 11, index = -1878877941 /* 0x9002990B */ }, - new EncodingData.TrieNode { valueOrNumChildren = 0x84, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x90, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x91, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x92, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x93, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x94, index = 35 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x95, index = 36 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x96, index = 37 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x97, index = 38 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x98, index = 39 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x99, index = 40 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 4, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xE0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 2, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB8, index = 11 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB9, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 3, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x88, index = 27 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xA5, index = 28 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xAA, index = 29 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 11, index = -1878877941 /* 0x9002990B */ }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x84, index = 30 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x90, index = 31 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x91, index = 32 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x92, index = 33 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x93, index = 34 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x94, index = 35 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x95, index = 36 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x96, index = 37 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x97, index = 38 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x98, index = 39 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x99, index = 40 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, + new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, }; - EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, thaiUtf8ParsingTrie, EncodingData.Encoding.Utf8); + EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, EncodingData.TextEncoding.Utf8, thaiUtf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseInt64(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); diff --git a/tests/System.Text.Primitives.Tests/PrimitiveParserTests.cs b/tests/System.Text.Primitives.Tests/PrimitiveParserTests.cs index e5080bf7767..bdb8567ed25 100644 --- a/tests/System.Text.Primitives.Tests/PrimitiveParserTests.cs +++ b/tests/System.Text.Primitives.Tests/PrimitiveParserTests.cs @@ -80,7 +80,7 @@ public unsafe void ParseUtf8SpanOfBytesToUInt32(string text, uint expectedValue, uint parsedValue; int bytesConsumed; - bool result = PrimitiveParser.TryParseUInt32(span, EncodingData.Encoding.Utf8, out parsedValue, out bytesConsumed); + bool result = PrimitiveParser.TryParseUInt32(span, EncodingData.TextEncoding.Utf8, out parsedValue, out bytesConsumed); Assert.True(result); Assert.Equal(expectedValue, parsedValue); From d0b33e6b80c810b18a1ebab99e524b4a24e4fe8d Mon Sep 17 00:00:00 2001 From: Krzysztof Cwalina Date: Mon, 14 Nov 2016 15:18:12 -0800 Subject: [PATCH 2/2] made TireNode internal --- .../{ => Formatters}/ArrayFormatter.cs | 0 .../{ => Formatters}/OutputFormatter.cs | 0 .../{ => Formatters}/SequenceFormatter.cs | 0 .../{ => Formatters}/StreamFormatter.cs | 0 .../{ => Formatters}/StringFormatter.cs | 0 .../System/Text/EncodingData.cs | 21 +- .../PrimitiveFormattingTests.cs | 11 + .../ParserTests.cs | 606 +++--------------- .../ParserTests.tt | 213 +++--- 9 files changed, 222 insertions(+), 629 deletions(-) rename src/System.Text.Formatting/System/Text/Formatting/{ => Formatters}/ArrayFormatter.cs (100%) rename src/System.Text.Formatting/System/Text/Formatting/{ => Formatters}/OutputFormatter.cs (100%) rename src/System.Text.Formatting/System/Text/Formatting/{ => Formatters}/SequenceFormatter.cs (100%) rename src/System.Text.Formatting/System/Text/Formatting/{ => Formatters}/StreamFormatter.cs (100%) rename src/System.Text.Formatting/System/Text/Formatting/{ => Formatters}/StringFormatter.cs (100%) diff --git a/src/System.Text.Formatting/System/Text/Formatting/ArrayFormatter.cs b/src/System.Text.Formatting/System/Text/Formatting/Formatters/ArrayFormatter.cs similarity index 100% rename from src/System.Text.Formatting/System/Text/Formatting/ArrayFormatter.cs rename to src/System.Text.Formatting/System/Text/Formatting/Formatters/ArrayFormatter.cs diff --git a/src/System.Text.Formatting/System/Text/Formatting/OutputFormatter.cs b/src/System.Text.Formatting/System/Text/Formatting/Formatters/OutputFormatter.cs similarity index 100% rename from src/System.Text.Formatting/System/Text/Formatting/OutputFormatter.cs rename to src/System.Text.Formatting/System/Text/Formatting/Formatters/OutputFormatter.cs diff --git a/src/System.Text.Formatting/System/Text/Formatting/SequenceFormatter.cs b/src/System.Text.Formatting/System/Text/Formatting/Formatters/SequenceFormatter.cs similarity index 100% rename from src/System.Text.Formatting/System/Text/Formatting/SequenceFormatter.cs rename to src/System.Text.Formatting/System/Text/Formatting/Formatters/SequenceFormatter.cs diff --git a/src/System.Text.Formatting/System/Text/Formatting/StreamFormatter.cs b/src/System.Text.Formatting/System/Text/Formatting/Formatters/StreamFormatter.cs similarity index 100% rename from src/System.Text.Formatting/System/Text/Formatting/StreamFormatter.cs rename to src/System.Text.Formatting/System/Text/Formatting/Formatters/StreamFormatter.cs diff --git a/src/System.Text.Formatting/System/Text/Formatting/StringFormatter.cs b/src/System.Text.Formatting/System/Text/Formatting/Formatters/StringFormatter.cs similarity index 100% rename from src/System.Text.Formatting/System/Text/Formatting/StringFormatter.cs rename to src/System.Text.Formatting/System/Text/Formatting/Formatters/StringFormatter.cs diff --git a/src/System.Text.Primitives/System/Text/EncodingData.cs b/src/System.Text.Primitives/System/Text/EncodingData.cs index c57f5ab10ae..4afb3cb4efa 100644 --- a/src/System.Text.Primitives/System/Text/EncodingData.cs +++ b/src/System.Text.Primitives/System/Text/EncodingData.cs @@ -42,18 +42,24 @@ public enum TextEncoding : byte // The index is formatted as such: 0xAABBCCDD, where AA = the min value, // BB = the index of the min value relative to the current node (1-indexed), // CC = the max value, and DD = the max value's index in the same coord-system as BB. - public struct ParsingTrieNode + internal struct ParsingTrieNode { public byte valueOrNumChildren; public int index; } - // TODO: make these private once bin file generator is used - public EncodingData(byte[][] digitsAndSymbols, TextEncoding encoding, ParsingTrieNode[] parsingTrie) + // this should be removed after CreateParsingTire is implemented + public EncodingData(byte[][] digitsAndSymbols, TextEncoding encoding, Tuple[] parsingTrie) { _digitsAndSymbols = digitsAndSymbols; _encoding = encoding; - _parsingTrie = parsingTrie; + + var tire = new ParsingTrieNode[parsingTrie.Length]; + for(int i=0; i[] s_utf8ParsingTrie = new Tuple[] { + Tuple.Create((byte)17, 0x3004390D), + Tuple.Create((byte)43, 18), + Tuple.Create((byte)45, 19), + Tuple.Create((byte)46, 20), + Tuple.Create((byte)48, 21), + Tuple.Create((byte)49, 22), + Tuple.Create((byte)50, 23), + Tuple.Create((byte)51, 24), + Tuple.Create((byte)52, 25), + Tuple.Create((byte)53, 26), + Tuple.Create((byte)54, 27), + Tuple.Create((byte)55, 28), + Tuple.Create((byte)56, 29), + Tuple.Create((byte)57, 30), + Tuple.Create((byte)69, 31), + Tuple.Create((byte)73, 32), + Tuple.Create((byte)78, 33), + Tuple.Create((byte)101, 34), + Tuple.Create((byte)0, 14), + Tuple.Create((byte)0, 13), + Tuple.Create((byte)0, 10), + Tuple.Create((byte)0, 0), + Tuple.Create((byte)0, 1), + Tuple.Create((byte)0, 2), + Tuple.Create((byte)0, 3), + Tuple.Create((byte)0, 4), + Tuple.Create((byte)0, 5), + Tuple.Create((byte)0, 6), + Tuple.Create((byte)0, 7), + Tuple.Create((byte)0, 8), + Tuple.Create((byte)0, 9), + Tuple.Create((byte)0, 16), + Tuple.Create((byte)0, 12), + Tuple.Create((byte)0, 15), + Tuple.Create((byte)0, 16), + }; + + static Tuple[] s_thais_utf8ParsingTrie = new Tuple[] { + Tuple.Create((byte)4, 0), + Tuple.Create((byte)43, 5), + Tuple.Create((byte)69, 6), + Tuple.Create((byte)101, 7), + Tuple.Create((byte)0xE0, 8), + Tuple.Create((byte)0, 14), + Tuple.Create((byte)0, 16), + Tuple.Create((byte)0, 16), + Tuple.Create((byte)2, 0), + Tuple.Create((byte)0xB8, 11), + Tuple.Create((byte)0xB9, 15), + Tuple.Create((byte)3, 0), + Tuple.Create((byte)0x88, 27), + Tuple.Create((byte)0xA5, 28), + Tuple.Create((byte)0xAA, 29), + Tuple.Create((byte)11, -1878877941 /* 0x9002990B */), + Tuple.Create((byte)0x84, 30), + Tuple.Create((byte)0x90, 31), + Tuple.Create((byte)0x91, 32), + Tuple.Create((byte)0x92, 33), + Tuple.Create((byte)0x93, 34), + Tuple.Create((byte)0x94, 35), + Tuple.Create((byte)0x95, 36), + Tuple.Create((byte)0x96, 37), + Tuple.Create((byte)0x97, 38), + Tuple.Create((byte)0x98, 39), + Tuple.Create((byte)0x99, 40), + Tuple.Create((byte)0, 10), + Tuple.Create((byte)0, 13), + Tuple.Create((byte)0, 12), + Tuple.Create((byte)0, 15), + Tuple.Create((byte)0, 0), + Tuple.Create((byte)0, 1), + Tuple.Create((byte)0, 2), + Tuple.Create((byte)0, 3), + Tuple.Create((byte)0, 4), + Tuple.Create((byte)0, 5), + Tuple.Create((byte)0, 6), + Tuple.Create((byte)0, 7), + Tuple.Create((byte)0, 8), + Tuple.Create((byte)0, 9), + }; + private byte[] UtfEncode(string s, bool utf16) { if (utf16) @@ -52,46 +134,8 @@ public unsafe void ParseCustomCultureByteArrayToByte(string text, bool expectSuc new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] - { - new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - }; - - EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); + + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, s_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseByte(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -280,46 +324,8 @@ public unsafe void ParseCustomCultureByteArrayToUshort(string text, bool expectS new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] - { - new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - }; - - EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); + + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, s_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseUInt16(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -508,46 +514,8 @@ public unsafe void ParseCustomCultureByteArrayToUint(string text, bool expectSuc new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] - { - new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - }; - - EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); + + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, s_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseUInt32(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -736,46 +704,8 @@ public unsafe void ParseCustomCultureByteArrayToUlong(string text, bool expectSu new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] - { - new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - }; - - EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); + + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, s_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseUInt64(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -968,46 +898,8 @@ public unsafe void ParseCustomCultureByteArrayToSbyte(string text, bool expectSu new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] - { - new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - }; - - EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); + + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, s_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseSByte(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -1044,51 +936,8 @@ public unsafe void ParseCustomCultureThaiByteArrayToSbyte(string text, bool expe 0x83, 0xE0, 0xB8, 0x8A, 0xE0, 0xB9, 0x88, 0xE0, 0xB8, 0x95, 0xE0, 0xB8, 0xB1, 0xE0, 0xB8, 0xA7, 0xE0, 0xB9, 0x80, 0xE0, 0xB8, 0xA5, 0xE0, 0xB8, 0x82 }, new byte[] { 69 }, new byte[] { 101 }, }; - var thaiUtf8ParsingTrie = new EncodingData.ParsingTrieNode[] - { - new EncodingData.ParsingTrieNode { valueOrNumChildren = 4, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xE0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 2, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB8, index = 11 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB9, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 3, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x88, index = 27 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xA5, index = 28 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xAA, index = 29 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 11, index = -1878877941 /* 0x9002990B */ }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x84, index = 30 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x90, index = 31 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x91, index = 32 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x92, index = 33 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x93, index = 34 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x94, index = 35 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x95, index = 36 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x96, index = 37 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x97, index = 38 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x98, index = 39 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x99, index = 40 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, - }; - EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, EncodingData.TextEncoding.Utf8, thaiUtf8ParsingTrie); + + EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, EncodingData.TextEncoding.Utf8, s_thais_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseSByte(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -1307,46 +1156,8 @@ public unsafe void ParseCustomCultureByteArrayToShort(string text, bool expectSu new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] - { - new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - }; - - EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); + + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, s_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseInt16(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -1383,51 +1194,8 @@ public unsafe void ParseCustomCultureThaiByteArrayToShort(string text, bool expe 0x83, 0xE0, 0xB8, 0x8A, 0xE0, 0xB9, 0x88, 0xE0, 0xB8, 0x95, 0xE0, 0xB8, 0xB1, 0xE0, 0xB8, 0xA7, 0xE0, 0xB9, 0x80, 0xE0, 0xB8, 0xA5, 0xE0, 0xB8, 0x82 }, new byte[] { 69 }, new byte[] { 101 }, }; - var thaiUtf8ParsingTrie = new EncodingData.ParsingTrieNode[] - { - new EncodingData.ParsingTrieNode { valueOrNumChildren = 4, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xE0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 2, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB8, index = 11 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB9, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 3, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x88, index = 27 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xA5, index = 28 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xAA, index = 29 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 11, index = -1878877941 /* 0x9002990B */ }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x84, index = 30 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x90, index = 31 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x91, index = 32 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x92, index = 33 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x93, index = 34 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x94, index = 35 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x95, index = 36 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x96, index = 37 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x97, index = 38 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x98, index = 39 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x99, index = 40 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, - }; - EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, EncodingData.TextEncoding.Utf8, thaiUtf8ParsingTrie); + + EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, EncodingData.TextEncoding.Utf8, s_thais_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseInt16(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -1646,46 +1414,8 @@ public unsafe void ParseCustomCultureByteArrayToInt(string text, bool expectSucc new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] - { - new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - }; - - EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); + + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, s_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseInt32(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -1722,51 +1452,8 @@ public unsafe void ParseCustomCultureThaiByteArrayToInt(string text, bool expect 0x83, 0xE0, 0xB8, 0x8A, 0xE0, 0xB9, 0x88, 0xE0, 0xB8, 0x95, 0xE0, 0xB8, 0xB1, 0xE0, 0xB8, 0xA7, 0xE0, 0xB9, 0x80, 0xE0, 0xB8, 0xA5, 0xE0, 0xB8, 0x82 }, new byte[] { 69 }, new byte[] { 101 }, }; - var thaiUtf8ParsingTrie = new EncodingData.ParsingTrieNode[] - { - new EncodingData.ParsingTrieNode { valueOrNumChildren = 4, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xE0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 2, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB8, index = 11 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB9, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 3, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x88, index = 27 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xA5, index = 28 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xAA, index = 29 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 11, index = -1878877941 /* 0x9002990B */ }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x84, index = 30 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x90, index = 31 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x91, index = 32 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x92, index = 33 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x93, index = 34 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x94, index = 35 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x95, index = 36 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x96, index = 37 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x97, index = 38 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x98, index = 39 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x99, index = 40 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, - }; - EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, EncodingData.TextEncoding.Utf8, thaiUtf8ParsingTrie); + + EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, EncodingData.TextEncoding.Utf8, s_thais_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseInt32(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -1985,46 +1672,8 @@ public unsafe void ParseCustomCultureByteArrayToLong(string text, bool expectSuc new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.ParsingTrieNode[] - { - new EncodingData.ParsingTrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - }; - - EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, utf8ParsingTrie); + + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, s_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseInt64(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -2061,51 +1710,8 @@ public unsafe void ParseCustomCultureThaiByteArrayToLong(string text, bool expec 0x83, 0xE0, 0xB8, 0x8A, 0xE0, 0xB9, 0x88, 0xE0, 0xB8, 0x95, 0xE0, 0xB8, 0xB1, 0xE0, 0xB8, 0xA7, 0xE0, 0xB9, 0x80, 0xE0, 0xB8, 0xA5, 0xE0, 0xB8, 0x82 }, new byte[] { 69 }, new byte[] { 101 }, }; - var thaiUtf8ParsingTrie = new EncodingData.ParsingTrieNode[] - { - new EncodingData.ParsingTrieNode { valueOrNumChildren = 4, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 43, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 69, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 101, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xE0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 2, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB8, index = 11 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xB9, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 3, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x88, index = 27 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xA5, index = 28 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0xAA, index = 29 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 11, index = -1878877941 /* 0x9002990B */ }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x84, index = 30 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x90, index = 31 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x91, index = 32 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x92, index = 33 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x93, index = 34 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x94, index = 35 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x95, index = 36 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x96, index = 37 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x97, index = 38 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x98, index = 39 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0x99, index = 40 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.ParsingTrieNode { valueOrNumChildren = 0, index = 9 }, - }; - EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, EncodingData.TextEncoding.Utf8, thaiUtf8ParsingTrie); + + EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, EncodingData.TextEncoding.Utf8, s_thais_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParseInt64(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); diff --git a/tests/System.Text.Primitives.Tests/ParserTests.tt b/tests/System.Text.Primitives.Tests/ParserTests.tt index f6f5079de6e..088d0b156b6 100644 --- a/tests/System.Text.Primitives.Tests/ParserTests.tt +++ b/tests/System.Text.Primitives.Tests/ParserTests.tt @@ -29,6 +29,88 @@ namespace System.Text.Primitives.Tests { public partial class PrimitiveParserTests { + static Tuple[] s_utf8ParsingTrie = new Tuple[] { + Tuple.Create((byte)17, 0x3004390D), + Tuple.Create((byte)43, 18), + Tuple.Create((byte)45, 19), + Tuple.Create((byte)46, 20), + Tuple.Create((byte)48, 21), + Tuple.Create((byte)49, 22), + Tuple.Create((byte)50, 23), + Tuple.Create((byte)51, 24), + Tuple.Create((byte)52, 25), + Tuple.Create((byte)53, 26), + Tuple.Create((byte)54, 27), + Tuple.Create((byte)55, 28), + Tuple.Create((byte)56, 29), + Tuple.Create((byte)57, 30), + Tuple.Create((byte)69, 31), + Tuple.Create((byte)73, 32), + Tuple.Create((byte)78, 33), + Tuple.Create((byte)101, 34), + Tuple.Create((byte)0, 14), + Tuple.Create((byte)0, 13), + Tuple.Create((byte)0, 10), + Tuple.Create((byte)0, 0), + Tuple.Create((byte)0, 1), + Tuple.Create((byte)0, 2), + Tuple.Create((byte)0, 3), + Tuple.Create((byte)0, 4), + Tuple.Create((byte)0, 5), + Tuple.Create((byte)0, 6), + Tuple.Create((byte)0, 7), + Tuple.Create((byte)0, 8), + Tuple.Create((byte)0, 9), + Tuple.Create((byte)0, 16), + Tuple.Create((byte)0, 12), + Tuple.Create((byte)0, 15), + Tuple.Create((byte)0, 16), + }; + + static Tuple[] s_thais_utf8ParsingTrie = new Tuple[] { + Tuple.Create((byte)4, 0), + Tuple.Create((byte)43, 5), + Tuple.Create((byte)69, 6), + Tuple.Create((byte)101, 7), + Tuple.Create((byte)0xE0, 8), + Tuple.Create((byte)0, 14), + Tuple.Create((byte)0, 16), + Tuple.Create((byte)0, 16), + Tuple.Create((byte)2, 0), + Tuple.Create((byte)0xB8, 11), + Tuple.Create((byte)0xB9, 15), + Tuple.Create((byte)3, 0), + Tuple.Create((byte)0x88, 27), + Tuple.Create((byte)0xA5, 28), + Tuple.Create((byte)0xAA, 29), + Tuple.Create((byte)11, -1878877941 /* 0x9002990B */), + Tuple.Create((byte)0x84, 30), + Tuple.Create((byte)0x90, 31), + Tuple.Create((byte)0x91, 32), + Tuple.Create((byte)0x92, 33), + Tuple.Create((byte)0x93, 34), + Tuple.Create((byte)0x94, 35), + Tuple.Create((byte)0x95, 36), + Tuple.Create((byte)0x96, 37), + Tuple.Create((byte)0x97, 38), + Tuple.Create((byte)0x98, 39), + Tuple.Create((byte)0x99, 40), + Tuple.Create((byte)0, 10), + Tuple.Create((byte)0, 13), + Tuple.Create((byte)0, 12), + Tuple.Create((byte)0, 15), + Tuple.Create((byte)0, 0), + Tuple.Create((byte)0, 1), + Tuple.Create((byte)0, 2), + Tuple.Create((byte)0, 3), + Tuple.Create((byte)0, 4), + Tuple.Create((byte)0, 5), + Tuple.Create((byte)0, 6), + Tuple.Create((byte)0, 7), + Tuple.Create((byte)0, 8), + Tuple.Create((byte)0, 9), + }; + private byte[] UtfEncode(string s, bool utf16) { if (utf16) @@ -105,46 +187,8 @@ namespace System.Text.Primitives.Tests new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.TrieNode[] - { - new EncodingData.TrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.TrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.TrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.TrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.TrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.TrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.TrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.TrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.TrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.TrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - }; - - EncodingData fd = new EncodingData(utf8digitsAndSymbols, utf8ParsingTrie, EncodingData.Encoding.Utf8); + + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, s_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParse<#=unsignedClasses[i]#>(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -316,46 +360,8 @@ namespace System.Text.Primitives.Tests new byte[] { 78, 97, 78, }, // NaN new byte[] { 69, }, // E }; - var utf8ParsingTrie = new EncodingData.TrieNode[] - { - new EncodingData.TrieNode { valueOrNumChildren = 17, index = 0x3004390D }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 18 }, - new EncodingData.TrieNode { valueOrNumChildren = 45, index = 19 }, - new EncodingData.TrieNode { valueOrNumChildren = 46, index = 20 }, - new EncodingData.TrieNode { valueOrNumChildren = 48, index = 21 }, - new EncodingData.TrieNode { valueOrNumChildren = 49, index = 22 }, - new EncodingData.TrieNode { valueOrNumChildren = 50, index = 23 }, - new EncodingData.TrieNode { valueOrNumChildren = 51, index = 24 }, - new EncodingData.TrieNode { valueOrNumChildren = 52, index = 25 }, - new EncodingData.TrieNode { valueOrNumChildren = 53, index = 26 }, - new EncodingData.TrieNode { valueOrNumChildren = 54, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 55, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 56, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 57, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 73, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 78, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - }; - - EncodingData fd = new EncodingData(utf8digitsAndSymbols, utf8ParsingTrie, EncodingData.Encoding.Utf8); + + EncodingData fd = new EncodingData(utf8digitsAndSymbols, EncodingData.TextEncoding.Utf8, s_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParse<#=signedClasses[i]#>(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed); @@ -392,51 +398,8 @@ namespace System.Text.Primitives.Tests 0x83, 0xE0, 0xB8, 0x8A, 0xE0, 0xB9, 0x88, 0xE0, 0xB8, 0x95, 0xE0, 0xB8, 0xB1, 0xE0, 0xB8, 0xA7, 0xE0, 0xB9, 0x80, 0xE0, 0xB8, 0xA5, 0xE0, 0xB8, 0x82 }, new byte[] { 69 }, new byte[] { 101 }, }; - var thaiUtf8ParsingTrie = new EncodingData.TrieNode[] - { - new EncodingData.TrieNode { valueOrNumChildren = 4, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 43, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 69, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 101, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xE0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 14 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 16 }, - new EncodingData.TrieNode { valueOrNumChildren = 2, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xB8, index = 11 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xB9, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 3, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x88, index = 27 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xA5, index = 28 }, - new EncodingData.TrieNode { valueOrNumChildren = 0xAA, index = 29 }, - new EncodingData.TrieNode { valueOrNumChildren = 11, index = -1878877941 /* 0x9002990B */ }, - new EncodingData.TrieNode { valueOrNumChildren = 0x84, index = 30 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x90, index = 31 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x91, index = 32 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x92, index = 33 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x93, index = 34 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x94, index = 35 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x95, index = 36 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x96, index = 37 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x97, index = 38 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x98, index = 39 }, - new EncodingData.TrieNode { valueOrNumChildren = 0x99, index = 40 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 10 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 13 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 12 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 15 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 0 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 1 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 2 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 3 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 4 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 5 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 6 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 7 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 8 }, - new EncodingData.TrieNode { valueOrNumChildren = 0, index = 9 }, - }; - EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, thaiUtf8ParsingTrie, EncodingData.Encoding.Utf8); + + EncodingData fd = new EncodingData(thaiUtf8DigitsAndSymbols, EncodingData.TextEncoding.Utf8, s_thais_utf8ParsingTrie); Format.Parsed nf = new Format.Parsed('R'); bool result = PrimitiveParser.TryParse<#=signedClasses[i]#>(UtfEncode(text, false), index, fd, nf, out parsedValue, out bytesConsumed);