dev

EntityConvert is a tool that allows you to quickly encode/decode HTML entities, and change some encoding and decoding settings.

Installation

Configuration

EntityConvert has an options menu with several encoding and decoding settings:

Encoding options
  • Convert text to decimal or hexadecimal (e.g. the lower case letter "z" as a decimal entity would be z, and z in hexadecimal).
  • Encode default XML entities only (&, ", ', <, >) and not other characters.
Decoding options

Input size

In case that the input is larger than 100,000 bytes, on which case the conversion may take a few seconds, a notice would pop up, asking you whether or not you wish to continue. It can be disabled via the settings as well, however, choosing to only convert "vital characters" (XML default entities) should speed up the conversion.

Entities decode

The decode tool can only decode number entities (decimal and hexadecimal) and the default XML entities. For instance, if you were to try and decode &nbsp; or &euro;, they would not be converted, however, you can also specify a list of additional entities to replace these entities as well.

Outputs

Note that EntityConvert only encodes characters in either decimal (like &#122;) or hexadecimal entities (like &#x7a;).

Custom entities

As EntityConvert only allows decoding the default XML entities and decimal/hexadecimal entities, for decoding entities like &nbsp;, &bull;, &euro; or &trade;, you'd need to use further customization for these entities. In order to do that, above the script import function in your JS page, place the following code to declare further entities that you'd like to code. On the example below, the entities are placed in the following object. Each property represents the entity's name (e.g. bull for &bull;, which produces •), and its property is the character that this entity represents. The values in this example are unicode-encoded, but you can use instead the actual characters:

EntityConvert = {
	"entities": {
		"custom": {
			"nbsp": "\u00a0", // non-breaking space
			"bull": "\u2022", // bullet sign •
			"trade": "\u2022", // trademark sign ™
			"copy": "\u00a9", // copyright sign ©
			"pound": "\u00a3" // pound sign £
		}
	}
}

This feature also allows you to decode "pseudo entities" in case you used custom entities that are not supported by web browsers.

Access

The feature is accessible in the following ways:


Text above can be found here (edit)