Character Entities

Prev Next

Introduction

Character entities are descriptive representations of characters which are not available on the keyboard. They begin with an ampersand (&), followed by a descriptive string or character code and conclude with a semicolon (;). Character entities are commonly used in HTML for web pages in order to avoid ambiguities with reserved symbols (e.g. < for HTML tags) and to display special characters. Character codes can be specified in both decimal and hexadecimal formats.

Similar to HTML, B4P supports a large number of character entities. See the description of dump entities() for a complete list of currently supported character entities.

In addition, B4P provides proprietary character entities to define special console output characters (e.g. text and background color and text attributes such as underscoring), as well as special keyboard input characters like cursor navigation keys in form of single characters.

In text inside single quotation marks, character entities are converted into their actual characters. The conversion takes place before program execution begins, quasi at compile time. Character entities are not converted in text inside double quotation marks.

  echo( 'Value is ≥ 100 €' );  // Text inside single quotation marks
  echo( "Value is ≥ 100 €" );  // Text inside double quotation marks - will show plain text
  echo( decode entities( "Value is ≥ 100 €" )); // Entities decoded at run-time

  echo( '€'); // EURO Sign - UNICODE hexadecimal code
  echo( '€' ); // EURO Sign - UNICODE decimal code
Value is ≥ 100 €
Value is ≥ 100 €
Value is ≥ 100 €


Try it yourself: Open LAN_Features_Character_Entities.b4p in B4P_Examples.zip. Decompress before use.

See also

encode entities
decode entities
dump entities
special keyboard input characters
special console output characters