2018-10-24 15:35:06 +08:00
|
|
|
#pragma once
|
|
|
|
|
2019-01-03 02:54:18 +08:00
|
|
|
namespace ft8 {
|
2019-11-09 17:54:05 +08:00
|
|
|
// Utility functions for characters and strings
|
|
|
|
|
|
|
|
const char * trim_front(const char *str);
|
|
|
|
void trim_back(char *str);
|
|
|
|
char * trim(char *str);
|
2018-10-24 15:35:06 +08:00
|
|
|
|
2019-01-03 02:54:18 +08:00
|
|
|
char to_upper(char c);
|
|
|
|
bool is_digit(char c);
|
|
|
|
bool is_letter(char c);
|
|
|
|
bool is_space(char c);
|
|
|
|
bool in_range(char c, char min, char max);
|
|
|
|
bool starts_with(const char *string, const char *prefix);
|
|
|
|
bool equals(const char *string1, const char *string2);
|
2018-12-28 04:33:07 +08:00
|
|
|
|
2019-01-03 02:54:18 +08:00
|
|
|
int char_index(const char *string, char c);
|
2018-10-28 16:39:39 +08:00
|
|
|
|
2019-01-03 02:54:18 +08:00
|
|
|
// Text message formatting:
|
|
|
|
// - replaces lowercase letters with uppercase
|
|
|
|
// - merges consecutive spaces into single space
|
|
|
|
void fmtmsg(char *msg_out, const char *msg_in);
|
2018-10-28 16:39:39 +08:00
|
|
|
|
2019-01-03 02:54:18 +08:00
|
|
|
// Parse a 2 digit integer from string
|
|
|
|
int dd_to_int(const char *str, int length);
|
|
|
|
|
|
|
|
// Convert a 2 digit integer to string
|
|
|
|
void int_to_dd(char *str, int value, int width, bool full_sign = false);
|
|
|
|
|
2019-11-09 17:54:05 +08:00
|
|
|
char charn(int c, int table_idx);
|
|
|
|
int nchar(char c, int table_idx);
|
2019-01-03 02:54:18 +08:00
|
|
|
}
|