<commit_before>using System;
using System.Diagnostics;
using System.Text;

namespace DnDns
{
    internal static class DnsHelpers
    {
        private const long Epoch = 621355968000000000;

        internal static byte[] CanonicaliseDnsName(string name, bool lowerCase)
        {
            if (!name.EndsWith("."))
            {
                name += ".";
            }

            if (name == ".")
            {
                return new byte[1];
            }

            StringBuilder sb = new StringBuilder();

            sb.Append('\0');

            for (int i = 0, j = 0; i < name.Length; i++, j++)
            {
                if (lowerCase)
                {
                    sb.Append(char.ToLower(name[i]));
                }
                else
                {
                    sb.Append(name[i]);
                }

                if (name[i] == '.')
                {
                    sb[i - j] = (char) (j & 0xff);
                    j = -1;
                }
            }

            sb[sb.Length - 1] = '\0';

            return Encoding.ASCII.GetBytes(sb.ToString());
        }

        internal static String DumpArrayToString(byte[] bytes)
        {<commit_msg>Use ToLowerInvariant() instead of ToLower() where appropriate<commit_after>using System;
using System.Diagnostics;
using System.Text;

namespace DnDns
{
    internal static class DnsHelpers
    {
        private const long Epoch = 621355968000000000;

        internal static byte[] CanonicaliseDnsName(string name, bool lowerCase)
        {
            if (!name.EndsWith("."))
            {
                name += ".";
            }

            if (name == ".")
            {
                return new byte[1];
            }

            StringBuilder sb = new StringBuilder();

            sb.Append('\0');

            for (int i = 0, j = 0; i < name.Length; i++, j++)
            {
                if (lowerCase)
                {
                    sb.Append(char.ToLowerInvariant(name[i]));
                }
                else
                {
                    sb.Append(name[i]);
                }

                if (name[i] == '.')
                {
                    sb[i - j] = (char) (j & 0xff);
                    j = -1;
                }
            }

            sb[sb.Length - 1] = '\0';

            return Encoding.ASCII.GetBytes(sb.ToString());
        }

        internal static String DumpArrayToString(byte[] bytes)
        {
{'fraction_non_alphanumeric': 0.11645774363121715, 'fraction_numerical': 0.021027092600080875, 'mean_word_length': 1.0395713107996702, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3729285', 'n_tokens_mistral': 719, 'n_tokens_neox': 646, 'n_words': 148}