CharacterTypes.h 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. /*
  2. * Copyright (c) 2021-2024, 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/StringView.h>
  10. #include <AK/Types.h>
  11. #include <LibUnicode/Forward.h>
  12. namespace Unicode {
  13. struct CodePointRange {
  14. u32 first { 0 };
  15. u32 last { 0 };
  16. };
  17. struct CodePointRangeComparator {
  18. constexpr int operator()(u32 code_point, CodePointRange const& range)
  19. {
  20. return (code_point > range.last) - (code_point < range.first);
  21. }
  22. };
  23. Optional<GeneralCategory> general_category_from_string(StringView);
  24. bool code_point_has_general_category(u32 code_point, GeneralCategory general_category);
  25. bool code_point_has_control_general_category(u32 code_point);
  26. bool code_point_has_space_separator_general_category(u32 code_point);
  27. Optional<Property> property_from_string(StringView);
  28. bool code_point_has_property(u32 code_point, Property property);
  29. bool code_point_has_emoji_property(u32 code_point);
  30. bool code_point_has_emoji_modifier_base_property(u32 code_point);
  31. bool code_point_has_emoji_presentation_property(u32 code_point);
  32. bool code_point_has_identifier_start_property(u32 code_point);
  33. bool code_point_has_identifier_continue_property(u32 code_point);
  34. bool code_point_has_regional_indicator_property(u32 code_point);
  35. bool code_point_has_variation_selector_property(u32 code_point);
  36. bool is_ecma262_property(Property);
  37. Optional<Script> script_from_string(StringView);
  38. bool code_point_has_script(u32 code_point, Script script);
  39. bool code_point_has_script_extension(u32 code_point, Script script);
  40. enum class BidiClass {
  41. ArabicNumber, // AN
  42. BlockSeparator, // B
  43. BoundaryNeutral, // BN
  44. CommonNumberSeparator, // CS
  45. DirNonSpacingMark, // NSM
  46. EuropeanNumber, // EN
  47. EuropeanNumberSeparator, // ES
  48. EuropeanNumberTerminator, // ET
  49. FirstStrongIsolate, // FSI
  50. LeftToRight, // L
  51. LeftToRightEmbedding, // LRE
  52. LeftToRightIsolate, // LRI
  53. LeftToRightOverride, // LRO
  54. OtherNeutral, // ON
  55. PopDirectionalFormat, // PDF
  56. PopDirectionalIsolate, // PDI
  57. RightToLeft, // R
  58. RightToLeftArabic, // AL
  59. RightToLeftEmbedding, // RLE
  60. RightToLeftIsolate, // RLI
  61. RightToLeftOverride, // RLO
  62. SegmentSeparator, // S
  63. WhiteSpaceNeutral, // WS
  64. };
  65. BidiClass bidirectional_class(u32 code_point);
  66. }