Collections functions
Encryption functions
General functions
Theme permission functions
Resource functions

config_encode()

Description

Utility function to encode the passed string to something that conforms to
the json spec for a string. Json doesn't allow strings with double-quotes,
backslashes or control characters in them. For double-quote and backslash,
the encoding is '\"' and '\\' respectively. The encoding for control
characters is of the form '\uxxx' where "xxx" is the UTF-8 4-digit hex
value of the encoded character.

Parameters

ColumnTypeDefaultDescription
$input
string $input the string that needs encoding

Return

an encoded version of $input

Location

include/plugin_functions.php lines 259 to 280

Definition

 
function config_encode($input)
    {
    
$output '';
    for (
$i 0$i strlen($input); $i++)
        {
        
$char substr($input$i1);
        if (
ord($char) < 32)
            {
            
$char '\\u' substr('0000' dechex(ord($char)),-4);
            }
        elseif (
$char == '"')
            {
            
$char '\\"';
            }
        elseif (
$char == '\\')
            {
            
$char '\\\\';
            }
        
$output .= $char;
        }
    return 
$output;
    }   

This article was last updated 14th July 2020 03:35 Europe/London time based on the source file dated 2nd July 2020 09:08 Europe/London time.