(view source code of asc.cs as plain text)
using System;
namespace RobvanderWoude{ class Asc {static readonly string progver = "1.02";
static int Main( string[] args )
{if ( args.Length != 1 || ( args.Length == 1 && args[0] == "/?" ) || ( args.Length == 1 && Console.IsInputRedirected ) )
{return ShowHelp( string.Empty );
}string input;
if ( Console.IsInputRedirected )
{input = Console.In.ReadToEnd( ).Substring( 0, 1 );
} else {input = args[0].Substring( 0, 1 );
} try {int result = Convert.ToInt32( Convert.ToByte( Convert.ToChar( input ) ) );
Console.WriteLine( "{0}", result );
return result;
}catch ( Exception e )
{return ShowHelp( e.Message );
} }public static int ShowHelp( string errorMessage = "" )
{ /* Asc, Version 1.02 Return the decimal character code for the specified ASCII character Usage: ASC character or: some_program | ASC Where: character ASCII character some_program program generating an ASCII charachter Notes: Only the first character is processed, any characters following the first one will be ignored. The result will be displayed on screen and returned as exit code ("errorlevel"); in case of errors, exit code will be 0. This version of ASC requires .NET framework 4.5. Written by Rob van der Woude https://www.robvanderwoude.com */if ( !string.IsNullOrWhiteSpace( errorMessage ) )
{Console.Error.WriteLine( );
Console.ForegroundColor = ConsoleColor.Red;
Console.Error.Write( "ERROR: " );
Console.ForegroundColor = ConsoleColor.White;
Console.Error.WriteLine( errorMessage );
Console.ResetColor( );
}Console.Error.WriteLine( );
Console.Error.WriteLine( "Asc, Version {0}", progver );
Console.Error.WriteLine( "Return the decimal character code for the specified ASCII character" );
Console.Error.WriteLine( );
Console.Error.Write( "Usage: " );
Console.ForegroundColor = ConsoleColor.White;
Console.Error.WriteLine( "ASC character" );
Console.ResetColor( );
Console.Error.WriteLine( );
Console.Error.Write( " or: " );
Console.ForegroundColor = ConsoleColor.White;
Console.Error.WriteLine( "some_program | ASC" );
Console.ResetColor( );
Console.Error.WriteLine( );
Console.Error.Write( "Where: " );
Console.ForegroundColor = ConsoleColor.White;
Console.Error.Write( "character" );
Console.ResetColor( );
Console.Error.WriteLine( " ASCII character" );
Console.ForegroundColor = ConsoleColor.White;
Console.Error.Write( " some_program" );
Console.ResetColor( );
Console.Error.WriteLine( " program generating an ASCII charachter" );
Console.Error.WriteLine( );
Console.Error.WriteLine( "Notes: Only the first character is processed, any characters" );
Console.Error.WriteLine( " following the first one will be ignored." );
Console.Error.WriteLine( " The result will be displayed on screen and returned as exit" );
Console.Error.WriteLine( " code (\"errorlevel\"); in case of errors, exit code will be 0." );
Console.Error.WriteLine( " This version of ASC requires .NET framework 4.5." );
Console.Error.WriteLine( );
Console.Error.WriteLine( "Written by Rob van der Woude" );
Console.Error.WriteLine( "https://www.robvanderwoude.com" );
return 0;
} }}page last modified: 2025-10-11; loaded in 0.0073 seconds