summaryrefslogtreecommitdiff
path: root/AK/Utf8View.h
AgeCommit message (Collapse)Author
2021-05-21AK: Add Utf8View::iterator_at_byte_offset methodMax Wipfli
This implements a method to get a Utf8CodepointIterator at a specified byte offset.
2021-05-21AK: Add substring methods to Utf8ViewMax Wipfli
This patch implements a Unicode-safe substring method, which can be used when offset and length should be specified in actual characters instead of bytes. This can be used to mitigate issues where a string is split in the middle of a UTF-8 multi-byte character, which leads to invalid UTF-8. Furthermore, it implements to common shorthands for substring methods which take only an offset and return the substring until the end of the string.
2021-05-21AK: Change some argument and return types in Utf8View from int to size_tMax Wipfli
This changes the return type of Utf8View::byte_length and the argument types of substring_view from int to size_t.
2021-04-22Everything: Move to SPDX license identifiers in all files.Brian Gianforcaro
SPDX License Identifiers are a more compact / standardized way of representing file license information. See: https://spdx.dev/resources/use/#identifiers This was done with the `ambr` search and replace tool. ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-03-25AK: Add starts_with to Utf8ViewIdan Horowitz
Unlike String/StringView::starts_with this compares utf8 code points instead of "characters" (bytes), which is important when handling aribtary utf-8 input that could include overlong characters.
2021-01-12AK: Simplify constructors and conversions from nullptr_tLenny Maiorani
Problem: - Many constructors are defined as `{}` rather than using the ` = default` compiler-provided constructor. - Some types provide an implicit conversion operator from `nullptr_t` instead of requiring the caller to default construct. This violates the C++ Core Guidelines suggestion to declare single-argument constructors explicit (https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c46-by-default-declare-single-argument-constructors-explicit). Solution: - Change default constructors to use the compiler-provided default constructor. - Remove implicit conversion operators from `nullptr_t` and change usage to enforce type consistency without conversion.
2021-01-02AK: Use size_t in methods of Utf8View.asynts
2020-12-28LibGfx+AK: Make text elision work with multi-byte charactersAndreas Kling
This was causing WindowServer and Taskbar to crash sometimes when the stars aligned and we tried cutting off a string ending with "..." right on top of an emoji. :^)
2020-11-12AK: Prefer using instead of typedefLenny Maiorani
Problem: - `typedef` is a keyword which comes from C and carries with it old syntax that is hard to read. - Creating type aliases with the `using` keyword allows for easier future maintenance because it supports template syntax. - There is inconsistent use of `typedef` vs `using`. Solution: - Use `clang-tidy`'s checker called `modernize-use-using` to update the syntax to use the newer syntax. - Remove unused functions to make `clang-tidy` happy. - This results in consistency within the codebase.
2020-10-22AK: Make Utf8View and Utf32View more consistentTom
This enables use of these classes in templated code.
2020-08-05Unicode: Try s/codepoint/code_point/g againNico Weber
This time, without trailing 's'. Ran: git grep -l 'codepoint' | xargs sed -ie 's/codepoint/code_point/g
2020-08-05Revert "Unicode: s/codepoint/code_point/g"Nico Weber
This reverts commit ea9ac3155d1774f13ac4e9a96605c0e85a8f299e. It replaced "codepoint" with "code_points", not "code_point".
2020-08-03Unicode: s/codepoint/code_point/gAndreas Kling
Unicode calls them "code points" so let's follow their style.
2020-07-13LibJS: Add StringIteratorMatthew Olsson
2020-06-04AK: Allow default-constructing Utf8View and Utf8CodepointIteratorAndreas Kling
2020-05-18AK: Add a way to get the number of valid bytes in a Utf8ViewAnotherTest
2020-05-17AK: Add Utf8View::length_in_codepoints()Andreas Kling
2020-01-24Meta: Claim copyright for files created by meSergey Bugaev
This changes copyright holder to myself for the source code files that I've created or have (almost) completely rewritten. Not included are the files that were significantly changed by others even though it was me who originally created them (think HtmlView), or the many other files I've contributed code to.
2020-01-18Meta: Add license header to source filesAndreas Kling
As suggested by Joshua, this commit adds the 2-clause BSD license as a comment block to the top of every source file. For the first pass, I've just added myself for simplicity. I encourage everyone to add themselves as copyright holders of any file they've added or modified in some significant way. If I've added myself in error somewhere, feel free to replace it with the appropriate copyright holder instead. Going forward, all new source files should include a license header.
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-05Utf8View: Try fixing the travis-ci buildAndreas Kling
There's some overload ambiguity when doing Utf8View("literal")
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