summaryrefslogtreecommitdiff
path: root/AK/Utf8View.cpp
AgeCommit message (Collapse)Author
2019-12-09AK: Use size_t for the length of stringsAndreas Kling
Using int was a mistake. This patch changes String, StringImpl, StringView and StringBuilder to use size_t instead of int for lengths. Obviously a lot of code needs to change as a result of this.
2019-10-18UTF-8: Add Utf8CodepointIterator::codepoint_length_in_bytes()Andreas Kling
This allows you to retrieve the length (in bytes) of the codepoint the iterator is currently pointing at.
2019-09-15Utf8View: Don't print potentially unterminated string in debug messageAndreas Kling
2019-09-08AK: Fix buffer overrun in Utf8CodepointIterator::operator++Sergey Bugaev
The old implementation tried to move forward as long as the current byte looks like a UTF-8 character continuation byte (has its two most significant bits set to 10). This is correct as long as we assume the string is actually valid UTF-8, which we do (we also have a separate method that can check whether it is the case). We can't, however, assume that the data after the end of our string is also valid UTF-8 (in fact, we're not even allowed to look at data outside out string, but it happens to a valid memory region most of the time). If the byte after the end of our string also has its most significant bits set to 10, we would move one byte forward, and then fail the m_length > 0 assertion. One way to fix this would be to add a length check inside the loop condition. The other one, implemented in this commit, is to reimplement the whole function in terms of decode_first_byte(), which gives us the length as encoded in the first byte. This also brings it more in line with the other functions around it that do UTF-8 decoding.
2019-09-05Utf8View: Try fixing the travis-ci buildAndreas Kling
There's some overload ambiguity when doing Utf8View("literal")
2019-09-05AK: Log UTF-8 validation errorsSergey Bugaev
2019-09-05AK: Add some more utility methods to Utf8ViewSergey Bugaev
2019-08-28AK: Add a Utf8View type for iterating over UTF-8 codepointsSergey Bugaev
Utf8View wraps a StringView and implements begin() and end() that return a Utf8CodepointIterator, which parses UTF-8-encoded Unicode codepoints and returns them as 32-bit integers. This is the first step towards supporting emojis in Serenity ^) https://github.com/SerenityOS/serenity/issues/490