General fixes.

This commit is contained in:
Xnoe 2020-07-08 22:57:21 +01:00 committed by Elsie
parent a8ae737b37
commit a11d4a6499

11
utf8.h
View File

@ -29,10 +29,17 @@ public:
bool operator==(char* cs) {return c==fetch32(&cs);} bool operator==(char* cs) {return c==fetch32(&cs);}
bool operator==(char32 cs) {return c==cs.c;} bool operator==(char32 cs) {return c==cs.c;}
uint32_t operator>>(int a) const {return c>>a;} uint32_t operator>>(int a) const {return c>>a;}
char* toChar() const {
return new char[4]{(char)(c>>24), (char)(c>>16), (char)(c>>8), (char)c};
}
}; };
std::ostream& operator<<(std::ostream& stream, const char32& c32) { std::ostream& operator<<(std::ostream& stream, const char32& c32) {
stream << (char)(c32>>24) << (char)(c32>>16) << (char)(c32>>8) << (char)c32.c; char* asChar = c32.toChar();
for (int i(0);i<4;i++)
if (asChar[i])
stream << asChar[i];
delete asChar;
return stream; return stream;
} }
@ -50,6 +57,8 @@ struct string32 {
for (int index(0); index < cs.size(); index++) { for (int index(0); index < cs.size(); index++) {
if (cs.at(index) == find.cs.at(havematched)) if (cs.at(index) == find.cs.at(havematched))
havematched++; havematched++;
else
havematched=0;
if (havematched == findsize) { if (havematched == findsize) {
index -= findsize-1; index -= findsize-1;
cs.erase(cs.begin()+index, cs.begin()+index+findsize); cs.erase(cs.begin()+index, cs.begin()+index+findsize);