fix: String truncating being completely borken
This commit is contained in:
parent
77301fd018
commit
19e5aafc85
@ -693,8 +693,7 @@ namespace hex {
|
|||||||
it = string.begin() + maxLength / 2;
|
it = string.begin() + maxLength / 2;
|
||||||
|
|
||||||
// Try to find a UTF-8 character boundary
|
// Try to find a UTF-8 character boundary
|
||||||
while (it != string.begin() && (*it & 0x80) == 0x00) --it;
|
while (it != string.begin() && (*it & 0xC0) == 0x80) --it;
|
||||||
--it;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we still didn't find a valid boundary, just return the string as is
|
// If we still didn't find a valid boundary, just return the string as is
|
||||||
@ -712,8 +711,7 @@ namespace hex {
|
|||||||
it = string.end() - 1 - maxLength / 2;
|
it = string.end() - 1 - maxLength / 2;
|
||||||
|
|
||||||
// Try to find a UTF-8 character boundary
|
// Try to find a UTF-8 character boundary
|
||||||
while (it != string.end() && (*it & 0x80) == 0x00) ++it;
|
while (it != string.end() && (*it & 0xC0) == 0x80) ++it;
|
||||||
++it;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result + std::string(it, string.end());
|
return result + std::string(it, string.end());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user