diff options
Diffstat (limited to 'src/string.cc')
| -rw-r--r-- | src/string.cc | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/string.cc b/src/string.cc index 353a9f4e..551add2d 100644 --- a/src/string.cc +++ b/src/string.cc @@ -118,6 +118,21 @@ void String::Data::clear() set_empty(); } +String::String(Codepoint cp, CharCount count) +{ + reserve(utf8::codepoint_size(cp) * (int)count); + while (count-- > 0) + utf8::dump(std::back_inserter(*this), cp); +} + +String::String(Codepoint cp, ColumnCount count) +{ + int cp_count = (int)(count / max(codepoint_width(cp), 1_col)); + reserve(utf8::codepoint_size(cp) * cp_count); + while (cp_count-- > 0) + utf8::dump(std::back_inserter(*this), cp); +} + void String::resize(ByteCount size, char c) { const size_t target_size = (size_t)size; |
