sqlite3_snprintf() — Format a string
char* sqlite3_snprintf( int bytes, char* buf, const char* format, ... );
The number of bytes available in the output buffer.
A pre-allocated buffer to receive the formatted string.
The format string used to build the output
string. This is similar to the standard
printf() style formatted
string, but it supports a few extra formatting
Message formatting parameters.
A pointer to the formatted string buffer.
This function formats and builds a UTF-8 string in the provided
buffer. It is designed to mimic the standard
snprintf() function. Assuming
the provided buffer is one byte or larger, the string will
always be null-terminated.
Note that the first two parameters of
sqlite3_snprintf() are reversed from the
snprintf() returns the
number of characters in the output string, while
sqlite3_snprintf() returns a
pointer to the buffer passed in by the application.
In addition to the standard
formatting flags, all SQLite
printf() style functions also support the
%q flag is similar to
%s, only it will
sanitize the string for use as an SQL string literal. Mostly,
this consists of doubling all the single quote characters
') to form a proper
SQL escape (
%q will take the input
O'Reilly and output
O''Reilly. The formatted string should contain enclosing ...