1 /* xbt/trim.h -- Declarations of the functions ltrim(), rtrim() and trim() */
3 /* Copyright (c) 2007 Cherier Malek. All rights reserved. */
5 /* This program is free software; you can redistribute it and/or modify it
6 * under the terms of the license (GNU LGPL) which comes with this package. */
18 /** @brief Strip whitespace (or other characters) from the end of a string.
20 * The function rtrim() returns a string with whitespace stripped from the end of s.
21 * By default (without the second parameter char_list), rtrim() will strip these characters :
23 * - " " (ASCII 32 (0x20)) space.
24 * - "\t" (ASCII 9 (0x09)) tab.
25 * - "\n" (ASCII 10 (0x0A)) line feed.
26 * - "\r" (ASCII 13 (0x0D)) carriage return.
27 * - "\0" (ASCII 0 (0x00)) NULL.
28 * - "\x0B" (ASCII 11 (0x0B)) vertical tab.
30 * @param s The string to strip.
31 * @param char_list A string which contains the characters you want to strip.
33 * @return If the specified is NULL the function returns NULL. Otherwise the
34 * function returns the string with whitespace stripped from the end.
37 rtrim(char* s, const char* char_list);
39 /** @brief Strip whitespace (or other characters) from the beginning of a string.
41 * The function ltrim() returns a string with whitespace stripped from the beginning of s.
42 * By default (without the second parameter char_list), ltrim() will strip these characters :
44 * - " " (ASCII 32 (0x20)) space.
45 * - "\t" (ASCII 9 (0x09)) tab.
46 * - "\n" (ASCII 10 (0x0A)) line feed.
47 * - "\r" (ASCII 13 (0x0D)) carriage return.
48 * - "\0" (ASCII 0 (0x00)) NULL.
49 * - "\x0B" (ASCII 11 (0x0B)) vertical tab.
51 * @param s The string to strip.
52 * @param char_list A string which contains the characters you want to strip.
54 * @return If the specified is NULL the function returns NULL. Otherwise the
55 * function returns the string with whitespace stripped from the beginning.
58 ltrim( char* s, const char* char_list);
61 /** @brief Strip whitespace (or other characters) from the end and the begining of a string.
63 * The function trim() returns a string with whitespace stripped from the end and the begining of s.
64 * By default (without the second parameter char_list), trim() will strip these characters :
66 * - " " (ASCII 32 (0x20)) space.
67 * - "\t" (ASCII 9 (0x09)) tab.
68 * - "\n" (ASCII 10 (0x0A)) line feed.
69 * - "\r" (ASCII 13 (0x0D)) carriage return.
70 * - "\0" (ASCII 0 (0x00)) NULL.
71 * - "\x0B" (ASCII 11 (0x0B)) vertical tab.
73 * @param s The string to strip.
74 * @param char_list A string which contains the characters you want to strip.
76 * @return If the specified is NULL the function returns NULL. Otherwise the
77 * function returns the string with whitespace stripped from the end and the begining.
80 trim(char* s, const char* char_list);
87 #endif /* !XBT_TRIM_H */