CharacterTypes.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright (c) 2021, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Forward.h>
  8. #include <AK/Optional.h>
  9. #include <AK/Span.h>
  10. #include <AK/String.h>
  11. #include <AK/Types.h>
  12. #include <LibUnicode/Forward.h>
  13. namespace Unicode {
  14. struct CodePointRange {
  15. u32 first { 0 };
  16. u32 last { 0 };
  17. };
  18. struct BlockName {
  19. CodePointRange code_point_range {};
  20. StringView display_name;
  21. };
  22. Optional<String> code_point_display_name(u32 code_point);
  23. Optional<StringView> code_point_block_display_name(u32 code_point);
  24. Optional<StringView> code_point_abbreviation(u32 code_point);
  25. Span<BlockName const> block_display_names();
  26. u32 canonical_combining_class(u32 code_point);
  27. Span<SpecialCasing const* const> special_case_mapping(u32 code_point);
  28. // Note: The single code point case conversions only perform simple case folding.
  29. // Use the full-string transformations for full case folding.
  30. u32 to_unicode_lowercase(u32 code_point);
  31. u32 to_unicode_uppercase(u32 code_point);
  32. String to_unicode_lowercase_full(StringView, Optional<StringView> locale = {});
  33. String to_unicode_uppercase_full(StringView, Optional<StringView> locale = {});
  34. Optional<GeneralCategory> general_category_from_string(StringView);
  35. bool code_point_has_general_category(u32 code_point, GeneralCategory general_category);
  36. Optional<Property> property_from_string(StringView);
  37. bool code_point_has_property(u32 code_point, Property property);
  38. bool is_ecma262_property(Property);
  39. Optional<Script> script_from_string(StringView);
  40. bool code_point_has_script(u32 code_point, Script script);
  41. bool code_point_has_script_extension(u32 code_point, Script script);
  42. Optional<Block> block_from_string(StringView);
  43. bool code_point_has_block(u32 code_point, Block block);
  44. bool code_point_has_grapheme_break_property(u32 code_point, GraphemeBreakProperty property);
  45. bool code_point_has_word_break_property(u32 code_point, WordBreakProperty property);
  46. bool code_point_has_sentence_break_property(u32 code_point, SentenceBreakProperty property);
  47. Vector<size_t> find_grapheme_segmentation_boundaries(Utf16View const&);
  48. Vector<size_t> find_word_segmentation_boundaries(Utf16View const&);
  49. Vector<size_t> find_sentence_segmentation_boundaries(Utf16View const&);
  50. }