From 94060a78c1bd182b21ec61468eb29569ad11e20b Mon Sep 17 00:00:00 2001 From: Xnoe Date: Mon, 13 Jul 2020 21:40:24 +0100 Subject: [PATCH] Various changes and additions. It's probably a lot worse now. --- utf8.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) diff --git a/utf8.h b/utf8.h index 592a763..74c02c6 100644 --- a/utf8.h +++ b/utf8.h @@ -60,7 +60,18 @@ struct string32 { size += c32.size; } } - string32() {} + string32(std::string s) { + char* sd = (char*)s.c_str(); + while (sd[0]) { + char32 c32 = char32(&sd); + cs.push_back(c32); + size += c32.size; + } + } + string32() { +// cs.push_back(char32("")); +// size++; + } int length() const { return cs.size(); } @@ -88,6 +99,11 @@ struct string32 { toReturn += s; return toReturn; } + string32 operator+(char* s) { + string32 toReturn = *this; + toReturn += s; + return toReturn; + } bool operator==(string32 s) { for (int i(0);i split(string32 delim) { std::vector toReturn; string32 temporary, throwaway; @@ -154,6 +192,12 @@ struct string32 { } }; +string32 operator+(char* s1, string32 s2) { + string32 toReturn = s1; + toReturn += s2; + return toReturn; +} + std::ostream& operator<<(std::ostream& stream, const string32& s32) { for (int i=0;i