some additional clever string functions More...
#include <stdio.h>
Go to the source code of this file.
Defines | |
#define | STRING_ADDON_H |
#define | _ASCII_BEL 0x07 |
#define | _ASCII_BS 0x08 |
#define | _ASCII_CR 0x0D |
#define | _ASCII_LF 0x0A |
#define | _ASCII_ESC 0x1B |
#define | _ASCII_DEL 0x7F |
#define | _ASCII_SPACE 0x20 |
#define | _ASCII_COMMA 0x2C |
#define | _STRING_EOS 0x00 |
Functions | |
void | r_trim (char *string, char sign) |
eleminates all signs at the end of a string which are equal to the given one | |
void | l_trim (char *string, char sign) |
eleminates all leading signs which are equal to the given one | |
void | trim (char *string, char sign) |
eleminates all signs of the given type at the end or at the beginning of a string | |
char * | strtrok_single_char (char *c_ptr_search, char c_search) |
searches for the first occurence of a single character in a string and creates a string with the content till this point. |
some additional clever string functions
Target/Compiler: AVR_MEGA / GCC(WinAVR)
\
#define _ASCII_BEL 0x07 |
"Bell"
#define _ASCII_BS 0x08 |
Back Space
#define _ASCII_COMMA 0x2C |
Comma
#define _ASCII_CR 0x0D |
Carriage Return
#define _ASCII_DEL 0x7F |
Delete
#define _ASCII_ESC 0x1B |
Escape
#define _ASCII_LF 0x0A |
Line Feed
#define _ASCII_SPACE 0x20 |
Space
#define _STRING_EOS 0x00 |
End of String
#define STRING_ADDON_H |
precompiler help
void l_trim | ( | char * | string, | |
char | sign | |||
) |
eleminates all leading signs which are equal to the given one
*string | - string to investigate | |
sign | - character which shall be eliminated |
This function eliminates all leading characters in a string. The character which shall be eliminated and the string to be checked have to be addressed in the call. ------------ Testcode sprintf(str_rcv_usart,""); l_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,"a"); l_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," test x"); l_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," test mit blanks "); l_trim(str_rcv_usart,_ASCII_SPACE);
void r_trim | ( | char * | string, | |
char | sign | |||
) |
eleminates all signs at the end of a string which are equal to the given one
*string | - string to investigate | |
sign | - character which shall be eliminated |
This function eliminates all characters at the end of a string. The character which shall be eliminated and the string to be checked have to be addressed in the call. ------------ Testcode sprintf(str_rcv_usart,""); r_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,"a"); r_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," test x "); r_trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," test mit blanks "); r_trim(str_rcv_usart,_ASCII_SPACE);
char* strtrok_single_char | ( | char * | c_ptr_search, | |
char | c_search | |||
) |
searches for the first occurence of a single character in a string and creates a string with the content till this point.
*c_ptr_search | - string used for search | |
c_search | - character which shall be searched |
searches for the first occurence of a single character in a string and replaces it with '/0'. It returns a pointer to the beginning of the "new" string if it found the character. The function remembers the last position where a character has been found. Calling the function with a c_ptr_search=NULL continuous the search at the stored location.
void trim | ( | char * | string, | |
char | sign | |||
) |
eleminates all signs of the given type at the end or at the beginning of a string
*string | - string to investigate | |
sign | - character which shall be eliminated |
This function eliminates all characters at the end and at the beginning of a string. The character which shall be eliminated and the string to be checked have to be addressed in the call. ------- Testcode sprintf(str_rcv_usart," op1"); trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,"a"); trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart," help aber woher%c ",toascii(13)); trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,""); trim(str_rcv_usart,_ASCII_SPACE); sprintf(str_rcv_usart,"help %c",toascii(13)); trim(str_rcv_usart,_ASCII_SPACE);