mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-22 09:19:03 +00:00
AK+LibUnicode: Expose TrailingCodePointTransformation in to_titlecase
Relocating the definition of this enum from LibUnicode to AK.
This commit is contained in:
@@ -17,6 +17,8 @@ template<size_t inline_capacity>
|
||||
class ByteBuffer;
|
||||
}
|
||||
|
||||
enum class TrailingCodePointTransformation : u8;
|
||||
|
||||
class BigEndianInputBitStream;
|
||||
class BigEndianOutputBitStream;
|
||||
class Bitmap;
|
||||
@@ -198,6 +200,7 @@ using AK::String;
|
||||
using AK::StringBuilder;
|
||||
using AK::StringImpl;
|
||||
using AK::StringView;
|
||||
using AK::TrailingCodePointTransformation;
|
||||
using AK::Traits;
|
||||
using AK::UnixDateTime;
|
||||
using AK::URL;
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
// Creates a new String by case-transforming this String. Using these methods require linking LibUnicode into your application.
|
||||
ErrorOr<String> to_lowercase(Optional<StringView> const& locale = {}) const;
|
||||
ErrorOr<String> to_uppercase(Optional<StringView> const& locale = {}) const;
|
||||
ErrorOr<String> to_titlecase(Optional<StringView> const& locale = {}) const;
|
||||
ErrorOr<String> to_titlecase(Optional<StringView> const& locale = {}, TrailingCodePointTransformation trailing_code_point_transformation = TrailingCodePointTransformation::Lowercase) const;
|
||||
ErrorOr<String> to_casefold() const;
|
||||
|
||||
// Compare this String against another string with caseless matching. Using this method requires linking LibUnicode into your application.
|
||||
|
||||
@@ -54,6 +54,13 @@ enum class SplitBehavior : unsigned {
|
||||
};
|
||||
AK_ENUM_BITWISE_OPERATORS(SplitBehavior);
|
||||
|
||||
enum class TrailingCodePointTransformation : u8 {
|
||||
// Default behaviour; Puts the first typographic letter unit of each word, if lowercase, in titlecase; the other characters in lowercase.
|
||||
Lowercase,
|
||||
// Puts the first typographic letter unit of each word, if lowercase, in titlecase; other characters are unaffected. (https://drafts.csswg.org/css-text/#valdef-text-transform-capitalize)
|
||||
PreserveExisting,
|
||||
};
|
||||
|
||||
struct MaskSpan {
|
||||
size_t start;
|
||||
size_t length;
|
||||
@@ -117,6 +124,7 @@ size_t count(StringView, char needle);
|
||||
using AK::CaseSensitivity;
|
||||
using AK::ReplaceMode;
|
||||
using AK::SplitBehavior;
|
||||
using AK::TrailingCodePointTransformation;
|
||||
using AK::TrimMode;
|
||||
using AK::TrimWhitespace;
|
||||
#endif
|
||||
|
||||
@@ -34,13 +34,6 @@ struct BlockName {
|
||||
StringView display_name;
|
||||
};
|
||||
|
||||
enum class TrailingCodePointTransformation : u8 {
|
||||
// Default behaviour; Puts the first typographic letter unit of each word, if lowercase, in titlecase; the other characters in lowercase.
|
||||
Lowercase,
|
||||
// Puts the first typographic letter unit of each word, if lowercase, in titlecase; other characters are unaffected. (https://drafts.csswg.org/css-text/#valdef-text-transform-capitalize)
|
||||
PreserveExisting,
|
||||
};
|
||||
|
||||
Optional<DeprecatedString> code_point_display_name(u32 code_point);
|
||||
Optional<StringView> code_point_block_display_name(u32 code_point);
|
||||
Optional<StringView> code_point_abbreviation(u32 code_point);
|
||||
|
||||
@@ -19,7 +19,6 @@ enum class Property : u8;
|
||||
enum class Script : u8;
|
||||
enum class SentenceBreakProperty : u8;
|
||||
enum class WordBreakProperty : u8;
|
||||
enum class TrailingCodePointTransformation : u8;
|
||||
|
||||
struct CodePointDecomposition;
|
||||
struct CurrencyCode;
|
||||
|
||||
@@ -28,10 +28,10 @@ ErrorOr<String> String::to_uppercase(Optional<StringView> const& locale) const
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
ErrorOr<String> String::to_titlecase(Optional<StringView> const& locale) const
|
||||
ErrorOr<String> String::to_titlecase(Optional<StringView> const& locale, TrailingCodePointTransformation trailing_code_point_transformation) const
|
||||
{
|
||||
StringBuilder builder;
|
||||
TRY(Unicode::Detail::build_titlecase_string(code_points(), builder, locale, Unicode::TrailingCodePointTransformation::Lowercase));
|
||||
TRY(Unicode::Detail::build_titlecase_string(code_points(), builder, locale, trailing_code_point_transformation));
|
||||
return builder.to_string();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user