encode entities
This function encodes the following special characters into character entities:
Characters | Character Entity Conversion |
---|---|
> | > (greater than) |
< | < (less than) |
" | " (double quotation marks) |
' | ' (apostrophe / single quotation marks) |
& | & (ampersand symbol) |
All control characters | nnn; (e.g. new line, tab, backspace, escape) |
ANSI 0 (NUL) | Will be ignored |
All non-ANSI characters | nnn; (e.g. &eur; ≥ é) |
Consecutive spaces |   (every 2nd space is converted) |
See dump entities() to obtain a complete list of entities B4P is supporting.
Vectorization: This function supports vectorization in the 1st function parameter.
Instead of providing a single value, you can provide a set or even a nested set which contain multiple values.
The function will then process every value and its return value contains a corresponding set containing all results.
Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter
1-2
No. | Type | Description |
---|---|---|
1 input |
string set |
input string This string contains entities to be encoded. Vectorization can be used to provide multiple strings in a (nested) set. |
Opt. 2 input |
boolean | use new line in html format If false: Converts to
|
Type | Description |
---|---|
string set |
String with encoded characters Converted string with decoded characters. If vectorization is used, then a set containing multiple strings is returned. |
Invalid character code (outside 0 - 1114111 range)
echo( encode entities( '4.50 € <TABLE> "..." </DIV>' ) );
echo( encode entities( Line 1 + new line + Line 2, false ) ); // use
echo( encode entities( Line 1 + new line + Line 2, true ) ); // use <BR/>
echo( encode entities( {Café,Caffè} ) ); // Vectorization example
4.50 €  <TABLE> "..." </DIV>
Line 1 Line 2
Line 1<BR/>Line 2
{'Café','Caffè'}