2024-08-14 15:46:19 -03:00
|
|
|
/*
|
2025-07-23 14:32:51 -03:00
|
|
|
* Copyright (c) 2024-2025, Tim Flynn <trflynn89@ladybird.org>
|
2024-08-14 15:46:19 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <AK/NonnullOwnPtr.h>
|
2026-06-21 14:03:10 -03:00
|
|
|
#include <AK/Utf16String.h>
|
2026-06-21 14:03:06 -03:00
|
|
|
#include <AK/Utf16View.h>
|
2024-08-14 15:46:19 -03:00
|
|
|
|
|
|
|
|
namespace Unicode {
|
|
|
|
|
|
|
|
|
|
enum class Usage {
|
|
|
|
|
Sort,
|
|
|
|
|
Search,
|
|
|
|
|
};
|
2026-06-21 14:03:06 -03:00
|
|
|
Usage usage_from_string(Utf16View);
|
2026-06-21 14:03:10 -03:00
|
|
|
Utf16String usage_to_string(Usage);
|
2024-08-14 15:46:19 -03:00
|
|
|
|
|
|
|
|
enum class Sensitivity {
|
|
|
|
|
Base,
|
|
|
|
|
Accent,
|
|
|
|
|
Case,
|
|
|
|
|
Variant,
|
|
|
|
|
};
|
2026-06-21 14:03:06 -03:00
|
|
|
Sensitivity sensitivity_from_string(Utf16View);
|
2026-06-21 14:03:10 -03:00
|
|
|
Utf16String sensitivity_to_string(Sensitivity);
|
2024-08-14 15:46:19 -03:00
|
|
|
|
|
|
|
|
enum class CaseFirst {
|
|
|
|
|
Upper,
|
|
|
|
|
Lower,
|
|
|
|
|
False,
|
|
|
|
|
};
|
2026-06-21 14:03:10 -03:00
|
|
|
CaseFirst case_first_from_string(Utf16View);
|
|
|
|
|
Utf16String case_first_to_string(CaseFirst);
|
2024-08-14 15:46:19 -03:00
|
|
|
|
|
|
|
|
class Collator {
|
|
|
|
|
public:
|
|
|
|
|
static NonnullOwnPtr<Collator> create(
|
Libraries: Clean up UTF-16 source text paths
Store parser errors, source range filenames, source code filenames,
module source, and Rust parser errors as UTF-16 where they flow back
into JavaScript-visible strings. Keep byte-oriented source buffers
byte-backed.
Remove temporary PrimitiveString, ByteString, and UTF-8 detours from
JSON, RegExp, module debug logging, print formatting, and tests.
2026-06-21 14:03:19 -03:00
|
|
|
Utf16View locale,
|
2024-08-14 15:46:19 -03:00
|
|
|
Usage,
|
Libraries: Clean up UTF-16 source text paths
Store parser errors, source range filenames, source code filenames,
module source, and Rust parser errors as UTF-16 where they flow back
into JavaScript-visible strings. Keep byte-oriented source buffers
byte-backed.
Remove temporary PrimitiveString, ByteString, and UTF-8 detours from
JSON, RegExp, module debug logging, print formatting, and tests.
2026-06-21 14:03:19 -03:00
|
|
|
Utf16View collation,
|
2024-08-14 17:18:06 -03:00
|
|
|
Optional<Sensitivity>,
|
2024-08-14 15:46:19 -03:00
|
|
|
CaseFirst,
|
|
|
|
|
bool numeric,
|
2024-08-14 16:53:47 -03:00
|
|
|
Optional<bool> ignore_punctuation);
|
2024-08-14 15:46:19 -03:00
|
|
|
|
|
|
|
|
virtual ~Collator() = default;
|
|
|
|
|
|
|
|
|
|
enum class Order {
|
|
|
|
|
Before,
|
|
|
|
|
Equal,
|
|
|
|
|
After,
|
|
|
|
|
};
|
2025-07-23 14:32:51 -03:00
|
|
|
virtual Order compare(Utf16View const&, Utf16View const&) const = 0;
|
2024-08-14 15:46:19 -03:00
|
|
|
|
2024-08-14 17:18:06 -03:00
|
|
|
virtual Sensitivity sensitivity() const = 0;
|
2024-08-14 16:53:47 -03:00
|
|
|
virtual bool ignore_punctuation() const = 0;
|
|
|
|
|
|
2024-08-14 15:46:19 -03:00
|
|
|
protected:
|
|
|
|
|
Collator() = default;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|