123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- #ifndef UTILS_H
- #define UTILS_H
- #include <fstream>
- #include <map>
- #include <string>
- // http://c-faq.com/lib/randrange.html
- int randint(int N);
- // http://c-faq.com/lib/randrange.html
- // numbers in the range [M, N] could be generated with something like
- int randrange(int M, int N);
- int random_activate(int w);
- /**
- * Display a repr of the given string.
- *
- * This converts most \n\r\v\f\t codes,
- * defaults to \xHH (hex value).
- */
- char *repr(const char *data);
- const char *logrepr(const char *input);
- const char *strnstr(const char *source, int len, const char *needle);
- int rstrnstr(const char *buffer, int len, const char *find);
- int string_insert(char *buffer, size_t max_length, size_t pos,
- const char *insert);
- void pcopy(char *pstring, char *str);
- std::string &find_new_text(std::ifstream &infile,
- std::streampos &last_position);
- void string_toupper(std::string &str);
- void string_trim(std::string &value);
- std::map<std::string, std::string> read_configfile(std::string filename);
- extern std::map<std::string, std::string> CONFIG;
- bool replace(std::string &str, const std::string &from, const std::string &to);
- void remove_all(std::string &str, char c);
- int unicode_len(char c);
- // int find_unicode(std::string &str, int pos);
- int harry_level(void);
- #include <iconv.h>
- class IConv {
- iconv_t ic;
- public:
- IConv(const char *to, const char *from);
- ~IConv();
- int convert(char *input, char *output, size_t outbufsize);
- };
- // IConv converter("UTF-8", "CP437");
- #endif
|