HtmlDecode plugin for Take Command / TCC / TCC/LE

Version 1.0.2.1     2023-10-12

Charles Dye

Purpose:

This plugin reimplements the @HTMLDECODE and @HTMLENCODE functions. It supports all HTML 4 character entities, and adds a few new features including support for high-order Unicode characters.

Installation:

To use this plugin, copy HtmlDecode.dll to some known location on your hard drive. (If you are still using the 32-bit version of Take Command, take HtmlDecode-x86.dll instead of HtmlDecode.dll.) Load the .DLL file with a PLUGIN /L command, for example:

plugin /l c:\bin\tcmd\test\htmldecode.dll

If you copy the .DLL file to a subdirectory named PlugIns within your Take Command program directory, it will be loaded automatically when TCC starts.

Plugin Features:

New functions: @HTMLDECODE, @HTMLENCODE

Syntax Note:

The syntax definitions in the following text use these conventions for clarity:

BOLD CODEindicates text which must be typed exactly as shown.
CODEindicates optional text, which may be typed as shown or omitted.
Bold italicnames a required argument; a value must be supplied.
Regular italicnames an optional argument.
ellipsis…after an argument means that more than one may be given.

New Functions:

@HTMLDECODE — Replaces HTML character entities in a string.

Syntax:
%@HTMLDECODE[string]

@HTMLDECODE recognizes all HTML 4 character entities, including &#nnn; and &#xnnnn; numeric entities. High-order Unicode characters are supported; for example, a cat emoji:

echo %@htmldecode[😸]

Numeric entities in the range U+0080 through U+009F (C1 control codes) will be remapped to characters from code page 1252.

Note that the returned string may contain ampersands, pipes, or redirection operators. You can deal with this by quoting the return value, or through liberal use of SETDOS /X to disable features.



@HTMLENCODE — Replaces characters in a string with HTML character entities.

Syntax:
%@HTMLENCODE[string]

At present, the only characters replaced are:

Character:Entity:
0x22"double quotes"
0x26&ampersand&
0x3C<less than&lt;
0x3E>greater than&gt;
0xA0 non-breaking space&nbsp;
control characters&#nn;
characters above U+FFFF&#xnnnnn;

Any characters in the range of %@CHAR[128] through %@CHAR[159] will be remapped to characters from code page 1252.

Note that the returned string is very likely to contain ampersands. You can deal with this by quoting the return value, or by using SETDOS to change or disable the command separator character.



Startup Message:

This plugin displays an informational line when it initializes. The message will be suppressed in transient or pipe shells. You can disable it for all shells by defining an environment variable named NOLOADMSG, for example:

set /e /u noloadmsg=1

Changes:


Version:Date:Changes:
1.0.2.12023-10-12Updated the plugin’s web address.
1.0.22023-07-28@HTMLENCODE no longer enitizes the vertical bar character. (No need, and &vert; isn’t a valid HTML 4 entity anyway.)
1.0.12022-06-17

Status and Licensing:

This plugin is © Copyright 2023, Charles Dye. Unaltered copies of the binary and documentation files may be freely distributed without restriction. I make no guarantee and give no warranty for its operation. If you find a problem, you can report it in the JP Software support forum.

Download:

You can download the current version of the plugin from http://charlesdye.net/dl/htmldecode.zip.