diff --git a/SharpNBT/EndianExtensions.cs b/SharpNBT/NumberExtensions.cs similarity index 89% rename from SharpNBT/EndianExtensions.cs rename to SharpNBT/NumberExtensions.cs index 8436ca8..9def7af 100644 --- a/SharpNBT/EndianExtensions.cs +++ b/SharpNBT/NumberExtensions.cs @@ -8,7 +8,7 @@ namespace SharpNBT; /// Contains extension methods dealing with endianness of numeric types. /// [PublicAPI] -public static class EndianExtensions +public static class NumberExtensions { /// /// Swap the endian of the given . @@ -71,4 +71,13 @@ public static class EndianExtensions var n = BitConverter.DoubleToInt64Bits(value); return BitConverter.Int64BitsToDouble(n.SwapEndian()); } + + public static bool IsValidUnquoted(this char c) + { + return c == '_' || c == '-' || + c == '.' || c == '+' || + c >= '0' && c <= '9' || + c >= 'A' && c <= 'Z' || + c >= 'a' && c <= 'z'; + } } \ No newline at end of file diff --git a/SharpNBT/SNBT/StringNbt.cs b/SharpNBT/SNBT/StringNbt.cs index 3619ff9..b9b2383 100644 --- a/SharpNBT/SNBT/StringNbt.cs +++ b/SharpNBT/SNBT/StringNbt.cs @@ -175,7 +175,7 @@ public static class StringNbt var start = scanner.Position; for (var length = 0; scanner.MoveNext(false, true); length++) { - if (AllowedInUnquoted(scanner.Current)) + if (scanner.Current.IsValidUnquoted()) continue; // Step back one character so not to consume the one that failed the permission check. @@ -365,15 +365,6 @@ public static class StringNbt return values; } - private static bool AllowedInUnquoted(char c) - { - return c == '_' || c == '-' || - c == '.' || c == '+' || - c >= '0' && c <= '9' || - c >= 'A' && c <= 'Z' || - c >= 'a' && c <= 'z'; - } - private const StringSplitOptions SplitOpts = StringSplitOptions.TrimEntries | StringSplitOptions.RemoveEmptyEntries; private static readonly char[] SplitSeparators = new[] { ',', 'b', 'B', 'l', 'L' }; } \ No newline at end of file