(Translated by https://www.hiragana.jp/)
GitHub - auberginehill/get-ascii-table: Generates ASCII Tables in a specified encoding to a specified location (a Windows PowerShell script).
Skip to content

Generates ASCII Tables in a specified encoding to a specified location (a Windows PowerShell script).

License

Notifications You must be signed in to change notification settings

auberginehill/get-ascii-table

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Get-AsciiTable.ps1

OS: Windows
Type: A Windows PowerShell script
Language: Windows PowerShell
Description: ASCII stands for American Standard Code for Information Interchange (ASCII).

Definition: The ASCII code is based on the English alphabet, and in the ASCII code a character such as 't' or '?' or an action of some sort is assigned with a numerical value.

ASCII was originally developed during the sixties for use with teleprinters and other teletypewriters (TTY) to code the messages, which were sent over various communications channels. The earliest teleprinters emulated the behavior of actual typewriters with rotating disks and other mechanical parts.

The character set in the ASCII code is fairly limited; the ASCII code consists of 128 characters, which include 33 non-printing control characters (that affect how the text is being processed, but are nowadays rarely used for their original purposes) and 95 printable characters. Unfortunately there isn't any unified version of "extended ASCII" characters, only different encoding systems, such as ISO 8859-1 (also called as ISO Latin-1), which may or may not build upon the ASCII characters.

Get-AsciiTable generates a series of numbers ranging from 0 to 255, and uses those numbers as a basis for the character retrieval system built in the PowerShell by using the "[char]number" -mechanism to recall a specific ASCII character. The HTML number generating parameters and other data has been added beforehand on the presumption that the enumeration starts from the first character (i.e. from the number zero character "(null)") and all the data is pretty much hard-coded. A far better solution would be that a current list would be fetched from somewhere, but good sources seem to be scarce and to connect to the Internet in this case seems a bit far fetched, too. This might, however, be an area of future development of Get-AsciiTable.

Homepage: https://github.com/auberginehill/get-ascii-table
Short URL: http://tinyurl.com/hdjlqdu
Version: 1.1
Sources:
Emojis: Emoji Table
Martin Pugh: Get-FolderSizes
Tobias Weltner: PowerTips Monthly Volume 2: Arrays and Hash Tables (or one of the archive.org versions)
PowerTip: Verify Default Output Encoding in PowerShell
CB.: Dynamic parameter accessing default value
Ravi Kochhar: ASCII Table: 7-bit
Network Working Group: ASCII format for Network Interchange
International Standard ISO 646 (Unofficial): The Set Of Control Characters Of ISO 646 (or one of the archive.org versions)
Downloads: For instance Get-AsciiTable.ps1. Or everything as a .zip-file.

Screenshot

      screenshot

Parameters

📐
  • Parameter -Path

    which has an alias called -ReportPath (so they both act exactly the same way). The -Path parameter specifies where the HTML ASCII Table and the adjacent CSV-file is to be saved. The default save location is $env:temp, which points to the current temporary file location, which is set in the system. The default -Path save location is defined at line 12 with the $Path variable. If no save location is defined in the command, the files are saved to $env:temp.

    It's not always mandatory to write -Path in the command to invoke the -Path parameter, as is shown in the Examples below, since Get-AsciiTable is trying to decipher the inputted commands as good as it is machinely possible within a 50 KB size limit.

    The save location path should should be valid file system path to a directory (a full path name of a directory (i.e. folder path such as C:\Windows)). In case the path name includes space characters, please add quotation marks around the path name. For usage, please see the Examples below and for more information about $env:temp please see the Notes section below.

  • Parameter -Sort

    Specifies which column is the primary sort column in the HTML ASCII Table and other outputs. Only one column may be selected in one query as the primary column. If -Sort parameter is not defined, Get-AsciiTable will try to sort by Decimal.

    In the HTML ASCII Table and other outputs all the headers are sortable (with the commands) and some headers have aliases, too. Valid -Sort values are listed below along with the default order (descending or ascending). Please also see the Examples section for further usage examples.

      Valid -Sort values:

      Value Sort Behavior Default Order
      Descending Ascending
      Genus Sort by Genus (param) Ascending
      Universal Sort by Universal (param) Ascending
      Name Sort by Name (param) Ascending
      Decimal Sort by Decimal (param) Ascending
      ASCII Sort by Value (param) Ascending
      Value Sort by Value (param) Ascending
      Type Sort by Type (param) Ascending
      "HTML Number" Sort by HTML Number (param) Ascending
      HTML Sort by HTML Number (param) Ascending
      Number Sort by Number (param) Ascending
      Character Sort by Character (param) Ascending
      Description Sort by Description (param) Ascending
      Subset Sort by Subset (param) Ascending
      Printable Sort by Printable (param) Ascending
      Encoding Sort by Encoding (param) Ascending

      In the table above, (param) depicts the usage of the -Descending parameter.

  • Parameter -Descending

    A switch to control how directories get sorted in the HTML ASCII Table and other outputs. Please see the -Sort parameter above for further details. By default Get-AsciiTable tries to sort everything in an ascending order. By adding the -Descending parameter to the command the prevalent ascending sort order may be reversed in the cases, which are listed in the table above and marked with (param).

  • Parameter -Encoding

    The -Encoding parameter sets the encoding in the generated CSV-file. Valid -Encoding values are listed below.

      Valid -Encoding values:

      Parameter Value Full Parameter with a Value
      -Encoding ASCII -Encoding ASCII
      BigEndianUnicode -Encoding BigEndianUnicode
      Default -Encoding Default
      Unicode -Encoding Unicode
      UTF7 -Encoding UTF7
      UTF8 -Encoding UTF8
      UTF32 -Encoding UTF32

    If the -Encoding parameter is not used in the command, the CSV-file will be written using the UTF8 encoding.

Outputs

➡️
  • Generates an HTML ASCII Table and an adjacent CSV-file in a specified Path ($Path = "$env:temp" at line 12), which is user-settable with the -Path parameter. Please notice, that there probably is a glitch in the generated CSV-file (for more information, please see the Notes section). Displays culture related information in console. In addition to that...

  • One pop-up window "$characters_selection" (Out-GridView) with sortable headers (with a click):
    1. Name Description
      $characters_selection Displays the ASCII Table

  • And also the aforementioned HTML-file "ASCII Table" and CSV-file at $Path. The HTML-file "ASCII Table" is opened automatically in the default browser after the query is finished.
    1. Path Type Name
      $env:temp\ascii_table.html HTML-file ascii_table.html
      $env:temp\ascii_table.csv CSV-file ascii_table.csv

Notes

⚠️
  • Please note that all the parameters can be used in one query command and that each of the parameters can be "tab completed" before typing them fully (by pressing the [tab] key).

  • Please note that when the eight ASCII character "(bell)" ([char]7 in the PowerShell language) is enumerated, an actual audible "bell" sound may occur. If that happens, it is intended action, and doesn't indicate nothing else than that the system in which Get-AsciiTable is run is following the ASCII principles by the book and is ASCII compatible. The "bell" sound is hard-coded to and assigned to the eight ASCII character, and is a reminescent of and a good representative of all the other control characters found amongst the first ASCII characters. The actual sound may vary according to the system and it may be agnostic to the OS sound level settings.
  • Please note that there is, however, probably an actual glitch happening. In the generated CSV-file on the second line (i.e. below the header row) the two first instances are written on a single line instead of each object (null-character and the start_of_heading-character) to their own line. This behavior seems to be prevalent, when the first ASCII character (null) (or as in the PowerShell language [char]0) enters the Export-Csv pipeline.
  • Please also note that the two files are created in a directory, which is end-user settable in each query command with the -Path parameter. The default save location is defined with the $Path variable (at line 12) and the -Path parameter also has an alias called -ReportPath. The default save location $env:temp variable points to the current temp folder. The default value of the $env:temp variable is C:\Users\<username>\AppData\Local\Temp (i.e. each user account has their own separate temp folder at path %USERPROFILE%\AppData\Local\Temp). To see the current temp path, for instance a command

    [System.IO.Path]::GetTempPath()

    may be used at the PowerShell prompt window [PS>]. To change the temp folder for instance to C:\Temp, please, for example, follow the instructions at Temporary Files Folder - Change Location in Windows, which in essence are something along the lines:
    1. Right click on Computer and click on Properties (or select Start → Control Panel → System). In the resulting window with the basic information about the computer...
    2. Click on Advanced system settings on the left panel and select Advanced tab on the resulting pop-up window.
    3. Click on the button near the bottom labeled Environment Variables.
    4. In the topmost section labeled User variables both TMP and TEMP may be seen. Each different login account is assigned its own temporary locations. These values can be changed by double clicking a value or by highlighting a value and selecting Edit. The specified path will be used by Windows and many other programs for temporary files. It's advisable to set the same value (a directory path) for both TMP and TEMP.
    5. Any running programs need to be restarted for the new values to take effect. In fact, probably also Windows itself needs to be restarted for it to begin using the new values for its own temporary files.

Examples

📖 To open this code in Windows PowerShell, for instance:

  1. ./Get-AsciiTable
    Run the script. Please notice to insert ./ or .\ before the script name. Uses the default location ($env:temp) for storing the generated HTML ASCII Table and the adjacent CSV-file to. Outputs the ASCII Table also in in a pop-up window (Out-GridView). The data is sorted by Decimal and ordered as ascending as default and the CSV-file is encoded in UTF8 as per default.
  2. help ./Get-AsciiTable -Full
    Display the help file.
  3. ./Get-AsciiTable -Path "C:\Scripts"
    Run the script and store the two ASCII Table files to C:\Scripts. The output is sorted, as per default, on the Decimal property in an ascending order, displaying the smallest numbers on top and the largest numbers at the bottom. Since the -Path variable has an alias of -ReportPath, a command

    ./Get-AsciiTable -ReportPath "C:\Scripts"

    will do the exactly same thing. Please note that the -Path is not mandatory in this example and that the quotation marks can be left out, since the path name doesn't contain any space characters (./Get-AsciiTable C:\Scripts).
  4. ./Get-AsciiTable -Path E:\chiore -Sort Value -Descending
    Run the script and save the files to E:\chiore. Sort the data based on the "Value" column and arrange the rows as descending so that the last ASCII characters come to the top and first ASCII characters will be at the bottom. To sort the same query in an ascending order the -Descending parameter may be left out from the query command (./Get-AsciiTable -Path E:\chiore -Sort Value).
  5. ./Get-AsciiTable -Path C:\Users\Dropbox -Encoding Unicode
    Will output the files to C:\Users\Dropbox and use the Unicode encoding, when writing the CSV-file. The output is sorted, as per default, on the Decimal property in an ascending order, displaying the smallest numbers on top and the largest numbers at the bottom.
  6. ./Get-AsciiTable -Path C:\Scripts -Sort Printable -Descending -Encoding UTF32
    Run the script and save the HTML ASCII Table and the adjacent CSV-file to C:\Scripts. Sort the data by the column name Printable in a descending order, and use UTF32 encoding, when writing the CSV-file. Please note, that -Path can be omitted in this example, because

    ./Get-AsciiTable C:\Scripts -Sort Printable -Descending -Encoding UTF32

    will result in the exact same outcome.
  7. Set-ExecutionPolicy remotesigned
    This command is altering the Windows PowerShell rights to enable script execution. Windows PowerShell has to be run with elevated rights (run as an administrator) to actually be able to change the script execution properties. The default value is "Set-ExecutionPolicy restricted".

    Parameters:

      Restricted Does not load configuration files or run scripts. Restricted is the default execution policy.
      AllSigned Requires that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the local computer.
      RemoteSigned Requires that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher.
      Unrestricted Loads all configuration files and runs all scripts. If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs.
      Bypass Nothing is blocked and there are no warnings or prompts.
      Undefined Removes the currently assigned execution policy from the current scope. This parameter will not remove an execution policy that is set in a Group Policy scope.

    For more information, please type "help Set-ExecutionPolicy -Full" or visit Set-ExecutionPolicy.

  8. New-Item -ItemType File -Path C:\Temp\Get-AsciiTable.ps1
    Creates an empty ps1-file to the C:\Temp directory. The New-Item cmdlet has an inherent -NoClobber mode built into it, so that the procedure will halt, if overwriting (replacing the contents) of an existing file is about to happen. Overwriting a file with the New-Item cmdlet requires using the Force.
    For more information, please type "help New-Item -Full".

Contributing

Find a bug? Have a feature request? Here is how you can contribute to this project:

contributing Bugs: Submit bugs and help us verify fixes.
Feature Requests: Feature request can be submitted by creating an Issue.
Edit Source Files: Submit pull requests for bug fixes and features and discuss existing proposals.

www

www Script Homepage
Martin Pugh: Get-FolderSizes
Tobias Weltner: PowerTips Monthly Volume 2: Arrays and Hash Tables (or one of the archive.org versions)
PowerTip: Verify Default Output Encoding in PowerShell
CB.: Dynamic parameter accessing default value
Ravi Kochhar: ASCII Table: 7-bit
ASCII format for Network Interchange
The Set Of Control Characters Of ISO 646 (or one of the archive.org versions)
Summary of ANSI standards for ASCII terminals
Using PowerShell to write a file in UTF-8 without the BOM
$OutputEncoding to the rescue
about_Preference_Variables
Windows PowerShell: Build a Better Function
ValidateSet Attribute Declaration
about_Functions_Advanced_Parameters
PowerShell: Advanced Function Parameter Attributes
Working with Hash Tables
ASCII Art: http://www.figlet.org/ and ASCII Art Text Generator

Related scripts

www Firefox Customization Files
Get-BatteryInfo
Get-ComputerInfo
Get-DirectorySize
Get-InstalledPrograms
Get-InstalledWindowsUpdates
Get-RAMInfo
Get-TimeDifference
Get-TimeZoneTable
Get-UnusedDriveLetters
Emoji Table
Java-Update
Rock-Paper-Scissors
Toss-a-Coin
Update-AdobeFlashPlayer

About

Generates ASCII Tables in a specified encoding to a specified location (a Windows PowerShell script).

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published