#include <glib.h>
Go to the source code of this file.
Defines | |
#define | __P(protos) protos |
Functions | |
GString* | g_string_strip (GString *str) |
Strip the string of any trailing white spaces. More... | |
void | g_string_delete_char (GString *str, gint pos) |
Delete a character from the string. More... | |
void | g_string_insert_char (GString *str, gchar chr, gint pos) |
Insert a character into a string. More... | |
void | g_string_insert_str (GString *str1, gchar *str2, gint pos) |
Insert a string into a string. More... | |
void | g_string_escape_char (GString *str, gchar chr) |
Backslash escape occurrances of characters within a string. More... | |
void | g_string_prepare_db_instr (GString *str) |
Prepare a SQL string for sending to the database. More... | |
void | g_string_prepare_html (GString *str) |
Prepare a string for use within an HTML document. More... |
The functions contained here perform useful operations on GStrings. Some of these functions are just nice things to be able to do, other functions are specific to working with PostgreSQL databases.
|
Delete a character from the string.
Delete the character at the position given. Shift all following characters to the left.
|
|
Backslash escape occurrances of characters within a string.
Sometimes characters need to be "backslash escaped" in order to be translated properly. For example if you want to put text containing single quotes into the text field of a database using SQL, you will need to backslash escape the single quotes.
The following code snippet will produce a string that contains: It\'s got\'s some single quotes, y\'all GString *str; str = g_string_new ("It's got's some single quotes, y'all"); g_string_escape_char (str, ''');
|
|
Insert a character into a string.
Insert a character into any spot within a string without overwritting the original contenets of the string. Chacters at and after the insert position are shifted to the right.
|
|
Insert a string into a string.
Insert a string into any spot within a string without overwritting the original contenets of the string. Chacters at and after the insert position are shifted to the right to make room for the string being inserted.
|
|
Prepare a SQL string for sending to the database.
Text data that is INSERT'ed or UPDATE'ed needs to be prepared before it can be used properly in an INSERT or UPDATE query. This function will strip any trailing white space, backslash escape any single quotes within the string, and surround the string with single quotes. If the string is empty or all white space, this function will return the string "NULL" (no quotes).
The following code snippet will produce a string that contains: 'It\'s got\'s some single quotes, y\'all' GString *str; str = g_string_new ("It's got's some single quotes, y'all"); g_string_prepare_db_instr (str);
|
|
Prepare a string for use within an HTML document.
Text that is displayed on an HTML document will need to be prepared so that characters that are used as part of the HTML syntax are replaced by their HTML symbols. Also, newline characters need to be changed into '
The following code snippet will produce a string that contins: This string has some <special> characters in it<br>dude. GString *str; str = g_string_new ("This string has some <special> characters in it\ndude."); g_string_prepare_html (str);
|
|
Strip the string of any trailing white spaces.
|