summaryrefslogtreecommitdiff
path: root/src/unistring.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/unistring.h')
-rw-r--r--src/unistring.h30
1 files changed, 17 insertions, 13 deletions
diff --git a/src/unistring.h b/src/unistring.h
index 5467a151..268f60e3 100644
--- a/src/unistring.h
+++ b/src/unistring.h
@@ -70,7 +70,7 @@ public:
std::size_t len = input.length();
VERIFY(utf8::is_valid(p, p + len));
- utf8::utf8to32(p, p + len, std::back_inserter(utf32chars));
+ utf8::unchecked::utf8to32(p, p + len, std::back_inserter(utf32chars));
}
~unistring() {
TRACE_DTOR(unistring);
@@ -80,18 +80,22 @@ public:
return utf32chars.size();
}
- std::string extract(const std::size_t begin = 0,
- const std::size_t len = 0) const
+ std::string extract(const std::string::size_type begin = 0,
+ const std::string::size_type len = 0) const
{
- std::string utf8result;
- std::size_t this_len = length();
+ std::string utf8result;
+ std::string::size_type this_len = length();
+
assert(begin <= this_len);
assert(begin + len <= this_len);
+
if (this_len)
- utf8::utf32to8(utf32chars.begin() + begin,
- utf32chars.begin() + begin +
- (len ? (len > this_len ? this_len : len) : this_len),
- std::back_inserter(utf8result));
+ utf8::unchecked::utf32to8
+ (utf32chars.begin() + begin,
+ utf32chars.begin() + begin +
+ (len ? (len > this_len ? this_len : len) : this_len),
+ std::back_inserter(utf8result));
+
return utf8result;
}
};
@@ -103,9 +107,9 @@ inline void justify(std::ostream& out,
bool redden = false)
{
if (! right) {
- if (redden) out << "\e[31m";
+ if (redden) out << "\033[31m";
out << str;
- if (redden) out << "\e[0m";
+ if (redden) out << "\033[0m";
}
unistring temp(str);
@@ -115,9 +119,9 @@ inline void justify(std::ostream& out,
out << ' ';
if (right) {
- if (redden) out << "\e[31m";
+ if (redden) out << "\033[31m";
out << str;
- if (redden) out << "\e[0m";
+ if (redden) out << "\033[0m";
}
}