Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 271 to 292

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 4th December 2024 08:35 Europe/London time based on the source file dated 29th November 2024 10:35 Europe/London time.