32 #define ERR_GENERAL LOG_STREAM(err, lg::general()) 45 if (count == 1 || count > 6) {
58 char32_t
uchar = *itor;
60 if(uchar <= static_cast<char32_t>(std::numeric_limits<wchar_t>::max()))
61 uchar = towlower(static_cast<wchar_t>(uchar));
65 res.append(itor.
substr().second, s.end());
71 std::size_t
index(
const std::string& str,
const std::size_t
index)
75 unsigned int i = 0, len = str.size();
77 for (
unsigned int chr=0; chr<index && i<len; ++chr) {
81 ERR_GENERAL <<
"Invalid UTF-8 string." << std::endl;
86 std::size_t
size(
const std::string& str)
88 unsigned int chr,
i = 0, len = str.size();
90 for (chr=0; i<len; ++chr) {
94 ERR_GENERAL <<
"Invalid UTF-8 string." << std::endl;
99 std::string&
insert(std::string& str,
const std::size_t pos,
const std::string&
insert)
101 return str.insert(
index(str, pos), insert);
104 std::string&
erase(std::string& str,
const std::size_t
start,
const std::size_t len)
106 if (start >
size(str))
return str;
107 unsigned pos =
index(str, start);
109 if (len == std::string::npos) {
111 return str.erase(pos);
113 return str.erase(pos,
index(str,start+len) - pos);
119 return erase(str, size);
124 std::u32string u4_str =
unicode_cast<std::u32string>(str);
125 if(u4_str.size() >
size) {
ucs4_convert_impl::enableif< TD, typename TS::value_type >::type unicode_cast(const TS &source)
void truncate_as_ucs4(std::string &str, const std::size_t size)
Truncates a UTF-8 string to the specified number of characters.
unsigned int count_leading_ones(N n)
Returns the quantity of leading 1 bits in n — i.e., the quantity of bits in n, minus the 1-based bit...
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
std::string & truncate(std::string &str, const std::size_t size)
Truncates a UTF-8 string to the specified number of characters.
const std::pair< typename string_type::const_iterator, typename string_type::const_iterator > & substr() const
static int byte_size_from_utf8_first(const unsigned char ch)
Functions for converting Unicode wide-char strings to UTF-8 encoded strings, back and forth...
Thrown by operations encountering invalid UTF-8 data.
static map_location::DIRECTION s
std::string & insert(std::string &str, const std::size_t pos, const std::string &insert)
Insert a UTF-8 string at the specified position.
std::size_t index(const std::string &str, const std::size_t index)
Codepoint index corresponding to the nth character in a UTF-8 string.
std::string lowercase(const std::string &s)
Returns a lowercased version of the string.
static iterator_base end(const string_type &str)
std::string & erase(std::string &str, const std::size_t start, const std::size_t len)
Erases a portion of a UTF-8 string.
static lg::log_domain log_engine("engine")
Standard logging facilities (interface).
EXIT_STATUS start(const std::string &filename, bool take_screenshot, const std::string &screenshot_filename)
Main interface for launching the editor from the title screen.