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

public static class ByteArrayExtensions
{
	/**
	 * Returns a hex string representation of the content
	 */
	public static string ToHexString (this byte[] bytes)
	{
		byte b;

		var res = new StringBuilder ();

		for (int bx = 0; bx < bytes.Length; bx++) {

			b = (byte)(bytes [bx] >> 4);
			res.Append ((char)(b > 9 ? b + 0x37 + 0x20 : b + 0x30));

			b = (byte)(bytes [bx] & 0x0F);
			res.Append ((char)(b > 9 ? b + 0x37 + 0x20 : b + 0x30));
		}

		return res.ToString ();
	}

	/**
	 * Decodes byte array to a C-string (each letter is 1 byte, 0 = end of text)
	 */
	public static string ToCString (this byte[] bytes)
	{
		var res = new StringBuilder ();

		foreach (byte x in bytes) {

			if (x == 0)
				break;

			res.Append ((char)x);
		}

		return res.ToString ();
	}

	/**
	 * Decodes byte array to a DOS $-terminated string (each letter is 1 byte, $ = end of text)
	 */
	public static string ToDosString (this byte[] bytes)
	{
		var res = new StringBuilder ();

		foreach (byte x in bytes) {
	
			if (x == (byte)'$')
				break;

			res.Append ((char)x);
		}

		return res.ToString ();
	}

	public static char[] ToCharArray (this byte[] bytes)
	{
		// TODO add test this method!
		char[] res = new char[bytes.Length];

		for (int i = 0; i < bytes.Length; i++)
			res [i] = (char)bytes [i];

		return res;
	}

	/**
	 * Returns an array shifted to the right by shift<commit_msg>add comment<commit_after>﻿using System;
using System.Text;

public static class ByteArrayExtensions
{
	/**
	 * Returns a hex string representation of the content
	 */
	public static string ToHexString (this byte[] bytes)
	{
		byte b;

		var res = new StringBuilder ();

		for (int bx = 0; bx < bytes.Length; bx++) {

			b = (byte)(bytes [bx] >> 4);
			res.Append ((char)(b > 9 ? b + 0x37 + 0x20 : b + 0x30));

			b = (byte)(bytes [bx] & 0x0F);
			res.Append ((char)(b > 9 ? b + 0x37 + 0x20 : b + 0x30));
		}

		return res.ToString ();
	}

	/**
	 * Decodes byte array to a C-string (each letter is 1 byte, 0 = end of text)
	 */
	public static string ToCString (this byte[] bytes)
	{
		var res = new StringBuilder ();

		foreach (byte x in bytes) {

			if (x == 0)
				break;

			res.Append ((char)x);
		}

		return res.ToString ();
	}

	/**
	 * Decodes byte array to a DOS $-terminated string (each letter is 1 byte, $ = end of text)
	 */
	public static string ToDosString (this byte[] bytes)
	{
		var res = new StringBuilder ();

		foreach (byte x in bytes) {
	
			if (x == (byte)'$')
				break;

			res.Append ((char)x);
		}

		return res.ToString ();
	}

	/** 
	 * Returns a char[] from the byte[]
	 */
	public static char[] ToCharArray (this byte[] bytes)
	{
		var res = new char[bytes.Length];

		for (int i = 0; i < bytes.Length; i++)
			res [i] = (char)bytes [i];

		return res;
	}

	/**
	 * Returns an array shifted to the right by shift
{'fraction_non_alphanumeric': 0.1505039972193257, 'fraction_numerical': 0.02015988877302746, 'mean_word_length': 2.713548387096774, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, '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': '4764657', 'n_tokens_mistral': 1177, 'n_tokens_neox': 990, 'n_words': 359}