decode entities

Prev Next

Function Names

decode entities

Description

This function decodes character entities entities (like € &#20ac; €) into actual characters.

Note: Character entities specified as string constants inside single quotation marks (as softquoted strings) in the B4P code will be converted automatically, quasi at compile time, and do not reuqire this function to be called.

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.

Call as: function

Restrictions

Indirect parameter passing is disabled
Vectorization is allowed in the 1st function parameter

Parameter count

1

Parameters

No.TypeDescription
1
input
string
set
input string

This string contains entity-encoded special characters. Vectorization can be used to provide multiple strings in a (nested) set.

Return value

TypeDescription
string
set
String with decoded characters

Converted string with decoded characters. If vectorization is used, then a set containing multiple strings is returned.

Exceptions

Invalid character code (outside 0 - 1114111 range)

Examples

               echo( decode entities( "4.50 € / 4.50 € / 4.50 € / 4.50 €" ) );
               echo( "4.50 €" ); // Quoted string are not decoded.
               echo( '4.50 €' ); // Softquoted string is already decoded implicitly.
               echo( '4.50 &eur' + 'o;' ); // This one is not because full entity is not in one softquoted string value
               echo( decode entities({"4.50 €", "Café" }) ); // Vectorization example

Output

4.50 € / 4.50 € / 4.50 € / 4.50 €
4.50 €
4.50 €
4.50 €
{'4.50 €','Café'}
Try it yourself: Open LIB_Function_decode_entities.b4p in B4P_Examples.zip. Decompress before use.

See also

chr
encode entities