Various Updates and Improvements

This commit is contained in:
Xnoe 2020-07-22 00:14:01 +01:00 committed by Elsie
parent 94060a78c1
commit 40d67cec6b

18
utf8.h
View File

@ -53,6 +53,7 @@ std::ostream& operator<<(std::ostream& stream, const char32& c32) {
struct string32 { struct string32 {
int size = 0; int size = 0;
std::vector<char32> cs; std::vector<char32> cs;
string32(char* sd) { string32(char* sd) {
while (sd[0]) { while (sd[0]) {
char32 c32 = char32(&sd); char32 c32 = char32(&sd);
@ -60,6 +61,7 @@ struct string32 {
size += c32.size; size += c32.size;
} }
} }
string32(std::string s) { string32(std::string s) {
char* sd = (char*)s.c_str(); char* sd = (char*)s.c_str();
while (sd[0]) { while (sd[0]) {
@ -68,10 +70,15 @@ struct string32 {
size += c32.size; size += c32.size;
} }
} }
string32() {
// cs.push_back(char32("")); string32(string32 from, int start, int end) {
// size++; cs.insert(cs.begin(), from.cs.begin()+start, from.cs.begin()+end);
for (char32 c : cs)
size += c.size;
} }
string32() {}
int length() const { int length() const {
return cs.size(); return cs.size();
} }
@ -99,6 +106,7 @@ struct string32 {
toReturn += s; toReturn += s;
return toReturn; return toReturn;
} }
string32 operator+(char* s) { string32 operator+(char* s) {
string32 toReturn = *this; string32 toReturn = *this;
toReturn += s; toReturn += s;
@ -190,6 +198,10 @@ struct string32 {
} }
return toReturn; return toReturn;
} }
int len() {
return cs.size();
}
}; };
string32 operator+(char* s1, string32 s2) { string32 operator+(char* s1, string32 s2) {