sqlite_safe_encode

mIRC SQLite

sqlite_safe_encode
Encodes data for safe use in files.
Syntax
$sqlite_safe_encode ( data [, delim ] )
Parameters
data
The data to be encoded.
delim
Optional. Delimiter in ASCII used to separate fields.
Return Value
Encoded data on success or $null on error.
Remarks
$sqlite_safe_encode is used by $sqlite_fetch_all internally to encode data so it can be safely written into a file.

The characters that are encoded are: \ (backslash), \n (newline), \r (carriage return), \0 (null-byte, in binary data) and whatever delimiter is used, if any. The characters are encoded as an escape sequence \xNN where NN is a two-digit hexadecimal number.

In case $null is returned it can mean an error, but it can also happen if you tried to encode an empty string. It should be ok to ignore this, but in case you want to determine whether $null meant an error or not, you can check the %sqlite_errno variable; if it's $SQLITE_OK there was no error.