- DateTimeCore: - Specify separator between date & time fof BiuildDateTimeStr(); - UtilCore: - Add UrlEncode() and UrlDecode() functions
57 lines
2.0 KiB
C
57 lines
2.0 KiB
C
/*
|
|
* UtilCore.h
|
|
*
|
|
* Created on: 14 April 2019
|
|
* Author: wentzelc
|
|
*/
|
|
|
|
#ifndef REDACORE_UTILCORE_H_
|
|
#define REDACORE_UTILCORE_H_
|
|
|
|
// Standard C/C++ Libraries
|
|
#include <ctype.h>
|
|
|
|
// redA Libraries
|
|
/* none */
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Convert raw bytes to string
|
|
char * BytesToSafeStr( const char * Bytes, const int Len, const bool NoCrLf = false, const char SpecChar = '.', char * OutBuf = NULL );
|
|
char * BytesToHexStr( const char * Bytes, const int Len, const char * Separator = " ", char * OutBuf = NULL );
|
|
char * BytesToBinStr( const char * Bytes, const int Len, const char * Separator = " ", char * OutBuf = NULL );
|
|
|
|
char * IntToBinStr( const int Bytes, const int Len, const char * Separator = " ", char * OutBuf = NULL );
|
|
|
|
// Convert string to raw bytes
|
|
inline u_int8_t HexToInt( char Digit ) {
|
|
if ((Digit >= '0') && (Digit <= '9')) return (Digit - '0');
|
|
else if ((Digit >= 'A') && (Digit <= 'F')) return (Digit - 'A'+10);
|
|
else if ((Digit >= 'a') && (Digit <= 'f')) return (Digit - 'a'+10);
|
|
else return 0;
|
|
}
|
|
char * HexStrToBytes( const char * Str, const int Len, const char * Separator = NULL, char * OutBuf = NULL );
|
|
char * BinStrToBytes( const char * Str, const int Len, const char * Separator = NULL, char * OutBuf = NULL );
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Search string data
|
|
char * StrSearch( const char * Haystack, const char * Needle, const int hLen = 0, const int nLen = 0 );
|
|
|
|
// Convert string to lower case
|
|
inline char * strlcase( char * Str ) {
|
|
for (char * Ch = Str; *Ch; Ch++ )
|
|
*Ch = tolower(*Ch);
|
|
return Str;
|
|
}
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// URL encoding & decoding
|
|
bool UrlEncode( const char * Input, char * Output, char ** EndPos = NULL );
|
|
bool UrlDecode( const char * Input, char * Output, char ** EndPos = NULL );
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
#endif /* REDACORE_UTILCORE_H_ */
|