Merge branch 'master' into jgrpp
# Conflicts: # projects/openttd_vs140.vcxproj.filters # projects/openttd_vs141.vcxproj.filters # projects/openttd_vs142.vcxproj.filters # src/base_consist.h # src/company_base.h # src/newgrf_config.cpp # src/newgrf_config.h # src/openttd.cpp # src/saveload/saveload.cpp # src/saveload/saveload.h # src/saveload/station_sl.cpp # src/settings.cpp # src/signs_base.h # src/string.cpp # src/string_func.h # src/table/misc_settings.ini # src/table/settings.h.preamble # src/town_cmd.cpp # src/vehicle.cpp # src/vehicle_cmd.cpp # src/video/cocoa/cocoa_v.mm # src/video/null_v.cpp
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#define STRING_FUNC_H
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <iosfwd>
|
||||
|
||||
#include "core/bitmath_func.hpp"
|
||||
#include "string_type.h"
|
||||
@@ -41,23 +42,11 @@ char *str_vfmt(const char *str, va_list ap);
|
||||
std::string CDECL stdstr_fmt(const char *str, ...) WARN_FORMAT(1, 2);
|
||||
std::string stdstr_vfmt(const char *str, va_list va);
|
||||
|
||||
char *str_validate_intl(char *str, const char *last, StringValidationSettings settings);
|
||||
|
||||
/**
|
||||
* Scans the string for valid characters and if it finds invalid ones,
|
||||
* replaces them with a question mark '?' (if not ignored)
|
||||
* @param str the string to validate
|
||||
* @param last the last valid character of str
|
||||
* @param settings the settings for the string validation.
|
||||
*/
|
||||
static inline void str_validate(char *str, const char *last, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK)
|
||||
{
|
||||
*str_validate_intl(str, last, settings) = '\0';
|
||||
}
|
||||
|
||||
char *str_validate(char *str, const char *last, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK);
|
||||
std::string str_validate(const std::string &str, StringValidationSettings settings = SVS_REPLACE_WITH_QUESTION_MARK);
|
||||
void ValidateString(const char *str);
|
||||
|
||||
void str_fix_scc_encoded(char *str, const char *last);
|
||||
const char *str_fix_scc_encoded(char *str, const char *last);
|
||||
void str_strip_colours(char *str);
|
||||
char *str_replace_wchar(char *str, const char *last, WChar find, WChar replace);
|
||||
bool strtolower(char *str);
|
||||
@@ -96,6 +85,7 @@ bool IsValidChar(WChar key, CharSetFilter afilter);
|
||||
|
||||
size_t Utf8Decode(WChar *c, const char *s);
|
||||
size_t Utf8Encode(char *buf, WChar c);
|
||||
size_t Utf8Encode(std::ostreambuf_iterator<char> &buf, WChar c);
|
||||
size_t Utf8TrimString(char *s, size_t maxlen);
|
||||
|
||||
|
||||
@@ -106,6 +96,14 @@ static inline WChar Utf8Consume(const char **s)
|
||||
return c;
|
||||
}
|
||||
|
||||
template <class Titr>
|
||||
static inline WChar Utf8Consume(Titr &s)
|
||||
{
|
||||
WChar c;
|
||||
s += Utf8Decode(&c, &*s);
|
||||
return c;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the length of a UTF-8 encoded character.
|
||||
* @param c Unicode character.
|
||||
|
Reference in New Issue
Block a user