//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// CommonHelpers satellite library | Author: Sergei Y.Kitáev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
using System;

#if !WASM
namespace CommonHelpers {
#else
namespace CommonHelpers.WASM {
#endif

//**************************************************************************************************
/// <summary>
/// </summary>
public static partial class HAscii {
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

/// <summary>0x00: Null (end of string)</summary>
public const int NUL=0x00;
/// <summary>0x01: Start of heading</summary>
public const int SOH=0x01;
/// <summary>0x02: Start of text</summary>
public const int STX=0x02;
/// <summary>0x03: End of text</summary>
public const int ETX=0x03;
/// <summary>0x04: End of transmission</summary>
public const int EOT=0x04;
/// <summary>0x05: Enquiry</summary>
public const int ENQ=0x05;
/// <summary>0x06: Acknowledge</summary>
public const int ACK=0x06;
/// <summary>0x07: Bell</summary>
public const int BEL=0x07;
/// <summary>0x08: Backspace</summary>
public const int BS=0x08;
/// <summary>0x09: Horizontal tab</summary>
public const int HT=0x09;
/// <summary>0x0A (10): Line feed</summary>
public const int LF=0x0A;
/// <summary>0x0A (10): New line</summary>
public const int NL=0x0A;
/// <summary>0x0B (11): vertical tab</summary>
public const int VT=0x0B;
/// <summary>0x0C (12): Form feed</summary>
public const int FF=0x0C;
/// <summary>0x0D (13): Carriage return</summary>
public const int CR=0x0D;
/// <summary>0x0E (14): Shift out</summary>
public const int SO=0x0E;
/// <summary>0x0F (15): Shift in</summary>
public const int SI=0x0F;
/// <summary>0x10 (16): Data line escape</summary>
public const int DLE=0x10;
/// <summary>0x11 (17): Dev ctrl 1</summary>
public const int DC1=0x11;
/// <summary>0x11 (17): X-ON</summary>
public const int XON=0x11;
/// <summary>0x12 (18): Device ctrl 2</summary>
public const int DC2=0x12;
/// <summary>0x13 (19): Dev ctrl 3</summary>
public const int DC3=0x13;
/// <summary>0x13 (19): X-OFF</summary>
public const int XOF=0x13;
/// <summary>0x14 (20): Device ctrl 4</summary>
public const int DC4=0x14;
/// <summary>0x15 (21): Negative acknowledge</summary>
public const int NAK=0x15;
/// <summary>0x16 (22): Synchronous idle</summary>
public const int SYN=0x16;
/// <summary>0x17 (23): End transmit block</summary>
public const int ETB=0x17;
/// <summary>0x18 (24): Cancel</summary>
public const int CAN=0x18;
/// <summary>0x19 (25): End of medium</summary>
public const int EM=0x19;
/// <summary>0x1A (26): Substitute</summary>
public const int SUB=0x1A;
/// <summary>0x1B (27): Escape</summary>
public const int ESC=0x1B;
/// <summary>0x1C (28): File separator</summary>
public const int FS=0x1C;
/// <summary>0x1D (29): Group separator</summary>
public const int GS=0x1D;
/// <summary>0x1E (30): Record separator</summary>
public const int RS=0x1E;
/// <summary>0x1F (31): Unit separator</summary>
public const int US=0x1F;

//--------------------------------------------------------------------------------------------------

/// <summary>0x7F (127): del symbol</summary>
/// <remarks>
/// This nonprintable code lies outside main control diapason (0x00..0x1F).
/// It is the last value of 7-bit code).
/// </remarks>
public const int DEL=0x7F;

//==================================================================================================

public static bool IsControl(int code)
{
   return IsControl(code,false);
}

public static bool IsControl(int code,bool accountDel)
{
   return
      code>=0 && code<0x20 ||
      accountDel && code==DEL;
}

//--------------------------------------------------------------------------------------------------

public static bool IsPrintable(char ch)
{
   return IsPrintable( (int)ch );
}

public static bool IsPrintable(int code)
{
   return code>=0x20 && code<=0x7E;
}

//--------------------------------------------------------------------------------------------------

public static bool IsLetter(char ch)
{
   return HOps.IsBetween(ch,'A','Z') || HOps.IsBetween(ch,'a','z');
}

public static bool IsLetter(int code)
{
   return HOps.IsBetween(code,0,UInt16.MaxValue) && IsLetter((char)code);
}

//==================================================================================================

static HAscii()
{
   CommonHelpers_Core.Access();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
} // HAscii
//**************************************************************************************************

} // CommonHelpers (.WASM)
