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. */
16 /** @brief Strip whitespace (or other characters) from the end of a string.
18 * The function rtrim() returns a string with whitespace stripped from the end of s.
19 * By default (without the second parameter char_list), rtrim() will strip these characters :
21 * - " " (ASCII 32 (0x20)) space.
22 * - "\t" (ASCII 9 (0x09)) tab.
23 * - "\n" (ASCII 10 (0x0A)) line feed.
24 * - "\r" (ASCII 13 (0x0D)) carriage return.
25 * - "\0" (ASCII 0 (0x00)) NULL.
26 * - "\x0B" (ASCII 11 (0x0B)) vertical tab.
28 * @param s The string to strip.
29 * @param char_list A string which contains the characters you want to strip.
31 * @return If the specified is NULL the function returns NULL. Otherwise the
32 * function returns the string with whitespace stripped from the end.
35 rtrim(char* s, const char* char_list);
37 /** @brief Strip whitespace (or other characters) from the beginning of a string.
39 * The function ltrim() returns a string with whitespace stripped from the beginning of s.
40 * By default (without the second parameter char_list), ltrim() will strip these characters :
42 * - " " (ASCII 32 (0x20)) space.
43 * - "\t" (ASCII 9 (0x09)) tab.
44 * - "\n" (ASCII 10 (0x0A)) line feed.
45 * - "\r" (ASCII 13 (0x0D)) carriage return.
46 * - "\0" (ASCII 0 (0x00)) NULL.
47 * - "\x0B" (ASCII 11 (0x0B)) vertical tab.
49 * @param s The string to strip.
50 * @param char_list A string which contains the characters you want to strip.
52 * @return If the specified is NULL the function returns NULL. Otherwise the
53 * function returns the string with whitespace stripped from the beginning.
56 ltrim( char* s, const char* char_list);
59 /** @brief Strip whitespace (or other characters) from the end and the begining of a string.
61 * The function trim() returns a string with whitespace stripped from the end and the begining of s.
62 * By default (without the second parameter char_list), trim() will strip these characters :
64 * - " " (ASCII 32 (0x20)) space.
65 * - "\t" (ASCII 9 (0x09)) tab.
66 * - "\n" (ASCII 10 (0x0A)) line feed.
67 * - "\r" (ASCII 13 (0x0D)) carriage return.
68 * - "\0" (ASCII 0 (0x00)) NULL.
69 * - "\x0B" (ASCII 11 (0x0B)) vertical tab.
71 * @param s The string to strip.
72 * @param char_list A string which contains the characters you want to strip.
74 * @return If the specified is NULL the function returns NULL. Otherwise the
75 * function returns the string with whitespace stripped from the end and the begining.
78 trim(char* s, const char* char_list);
82 #endif /* !XBT_TRIM_H */