From ed08af55321f4407d64450b1655a4c3aa094322f Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Sat, 24 Jun 2023 09:31:53 -0700 Subject: [PATCH 1/2] Breaking character defines into separate header --- .../blender/blenlib/BLI_string_utf8_symbols.h | 51 +++++++++++++++++++ source/blender/blenlib/CMakeLists.txt | 1 + .../blender/blenlib/intern/string_search.cc | 9 ++-- source/blender/editors/include/UI_interface.h | 3 +- .../interface/interface_icons_event.cc | 30 +++++------ .../editors/interface/interface_widgets.cc | 3 +- .../editors/space_sequencer/sequencer_edit.cc | 6 +-- source/blender/makesrna/intern/rna_wm.c | 45 +++++++++++----- .../blender/windowmanager/intern/wm_keymap.c | 30 ++++++----- 9 files changed, 127 insertions(+), 51 deletions(-) create mode 100644 source/blender/blenlib/BLI_string_utf8_symbols.h diff --git a/source/blender/blenlib/BLI_string_utf8_symbols.h b/source/blender/blenlib/BLI_string_utf8_symbols.h new file mode 100644 index 00000000000..dd75f23a859 --- /dev/null +++ b/source/blender/blenlib/BLI_string_utf8_symbols.h @@ -0,0 +1,51 @@ +/* SPDX-FileCopyrightText: 2023 Blender Foundation + * + * SPDX-License-Identifier: GPL-2.0-or-later */ + +#pragma once + +/** \file + * \ingroup bli + */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Unicode characters as UTF-8 strings. Last portion should include the official assigned name. + * Please do not add defines here that are not actually in use. */ + +#define BLI_STR_UTF8_MULTIPLICATION_SIGN u8"\u00D7" /* × */ +#define BLI_STR_UTF8_EM_DASH u8"\u2014" /* — */ +#define BLI_STR_UTF8_BULLET u8"\u2022" /* • */ +#define BLI_STR_UTF8_HORIZONTAL_ELLIPSIS u8"\u2026" /* … */ +#define BLI_STR_UTF8_LEFTWARDS_ARROW u8"\u2190" /* ← */ +#define BLI_STR_UTF8_UPWARDS_ARROW u8"\u2191" /* ↑ */ +#define BLI_STR_UTF8_RIGHTWARDS_ARROW u8"\u2192" /* → */ +#define BLI_STR_UTF8_DOWNWARDS_ARROW u8"\u2193" /* ↓ */ +#define BLI_STR_UTF8_UPWARDS_WHITE_ARROW u8"\u21E7" /* ⇧ */ +#define BLI_STR_UTF8_UP_ARROWHEAD u8"\u2303" /* ⌃ */ +#define BLI_STR_UTF8_PLACE_OF_INTEREST_SIGN u8"\u2318" /* ⌘ */ +#define BLI_STR_UTF8_OPTION_KEY u8"\u2325" /* ⌥ */ +#define BLI_STR_UTF8_ERASE_TO_THE_LEFT u8"\u232B" /* ⌫ */ +#define BLI_STR_UTF8_BROKEN_CIRCLE_WITH_NORTHWEST_ARROW u8"\u238B" /* ⎋ */ +#define BLI_STR_UTF8_RETURN_SYMBOL u8"\u23CE" /* ⏎ */ +#define BLI_STR_UTF8_BLACK_RIGHT_POINTING_DOUBLE_TRIANGLE_WITH_VERTICAL_BAR u8"\u23ED" /* ⏭ */ +#define BLI_STR_UTF8_BLACK_LEFT_POINTING_DOUBLE_TRIANGLE_WITH_VERTICAL_BAR u8"\u23EE" /* ⏮ */ +#define BLI_STR_UTF8_BLACK_RIGHT_POINTING_TRIANGLE_WITH_DOUBLE_VERTICAL_BAR u8"\u23EF" /* ⏯ */ +#define BLI_STR_UTF8_BLACK_SQUARE_FOR_STOP u8"\u23F9" /* ⏹ */ +#define BLI_STR_UTF8_OPEN_BOX u8"\u2423" /* ␣ */ +#define BLI_STR_UTF8_BLACK_RIGHT_POINTING_SMALL_TRIANGLE u8"\u25B8" /* ▸ */ +#define BLI_STR_UTF8_HORIZONTAL_TAB_KEY u8"\u2B7E" /* ⭾ */ +#define BLI_STR_UTF8_BLACK_DIAMOND_MINUS_WHITE_X u8"\u2756" /* ❖ */ + +/* Unicode characters as UTF-32 codepoints. Last portion should include the official assigned name. + * Please do not add defines here that are not actually in use. */ + +#define BLI_STR_UTF32_SPACE U'\u0020' /* */ +#define BLI_STR_UTF32_SLASH U'\u002F' /* / */ +#define BLI_STR_UTF32_BLACK_RIGHT_POINTING_SMALL_TRIANGLE U'\u25B8' /* ▸ */ + +#ifdef __cplusplus +} +#endif diff --git a/source/blender/blenlib/CMakeLists.txt b/source/blender/blenlib/CMakeLists.txt index c7afefa97b1..15a37fe7ee3 100644 --- a/source/blender/blenlib/CMakeLists.txt +++ b/source/blender/blenlib/CMakeLists.txt @@ -354,6 +354,7 @@ set(SRC BLI_string_ref.hh BLI_string_search.h BLI_string_utf8.h + BLI_string_utf8_symbols.h BLI_string_utils.h BLI_sub_frame.hh BLI_sys_types.h diff --git a/source/blender/blenlib/intern/string_search.cc b/source/blender/blenlib/intern/string_search.cc index 313a3635a2d..80448f24a3e 100644 --- a/source/blender/blenlib/intern/string_search.cc +++ b/source/blender/blenlib/intern/string_search.cc @@ -10,11 +10,12 @@ #include "BLI_string_ref.hh" #include "BLI_string_search.h" #include "BLI_string_utf8.h" +#include "BLI_string_utf8_symbols.h" #include "BLI_timeit.hh" /* Right arrow, keep in sync with #UI_MENU_ARROW_SEP in `UI_interface.h`. */ -#define UI_MENU_ARROW_SEP "\xe2\x96\xb8" -#define UI_MENU_ARROW_SEP_UNICODE 0x25b8 +#define UI_MENU_ARROW_SEP BLI_STR_UTF8_BLACK_RIGHT_POINTING_SMALL_TRIANGLE +#define UI_MENU_ARROW_SEP_UNICODE BLI_STR_UTF32_BLACK_RIGHT_POINTING_SMALL_TRIANGLE namespace blender::string_search { @@ -347,8 +348,8 @@ void extract_normalized_words(StringRef str, LinearAllocator<> &allocator, Vector &r_words) { - const uint32_t unicode_space = uint32_t(' '); - const uint32_t unicode_slash = uint32_t('/'); + const uint32_t unicode_space = BLI_STR_UTF32_SPACE; + const uint32_t unicode_slash = BLI_STR_UTF32_SLASH; const uint32_t unicode_right_triangle = UI_MENU_ARROW_SEP_UNICODE; BLI_assert(unicode_space == BLI_str_utf8_as_unicode(" ")); diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 2b3cd6a5a02..594b8575fcd 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -9,6 +9,7 @@ #pragma once #include "BLI_compiler_attrs.h" +#include "BLI_string_utf8_symbols.h" #include "BLI_sys_types.h" /* size_t */ #include "BLI_utildefines.h" #include "UI_interface_icons.h" @@ -87,7 +88,7 @@ typedef struct uiViewItemHandle uiViewItemHandle; /* Separator for text in search menus (right pointing arrow). * keep in sync with `string_search.cc`. */ -#define UI_MENU_ARROW_SEP "\xe2\x96\xb8" +#define UI_MENU_ARROW_SEP BLI_STR_UTF8_BLACK_RIGHT_POINTING_SMALL_TRIANGLE /* names */ #define UI_MAX_DRAW_STR 400 diff --git a/source/blender/editors/interface/interface_icons_event.cc b/source/blender/editors/interface/interface_icons_event.cc index 7e8ca39f105..9fd22ef67a7 100644 --- a/source/blender/editors/interface/interface_icons_event.cc +++ b/source/blender/editors/interface/interface_icons_event.cc @@ -79,12 +79,12 @@ void icon_draw_rect_input( icon_draw_rect_input_text(&rect, color, str, event_type > EVT_F9KEY ? 8.5f : 11.5f, 0.0f); } else if (event_type == EVT_LEFTSHIFTKEY) { /* Right Shift has already been converted to left. */ - const char str[] = {0xe2, 0x87, 0xa7, 0x0}; + const char str[] = BLI_STR_UTF8_UPWARDS_WHITE_ARROW; icon_draw_rect_input_text(&rect, color, str, 16.0f, 0.0f); } else if (event_type == EVT_LEFTCTRLKEY) { /* Right Shift has already been converted to left. */ if (platform == MACOS) { - const char str[] = {0xe2, 0x8c, 0x83, 0x0}; + const char str[] = BLI_STR_UTF8_UP_ARROWHEAD; icon_draw_rect_input_text(&rect, color, str, 21.0f, -8.0f); } else { @@ -93,7 +93,7 @@ void icon_draw_rect_input( } else if (event_type == EVT_LEFTALTKEY) { /* Right Alt has already been converted to left. */ if (platform == MACOS) { - const char str[] = {0xe2, 0x8c, 0xa5, 0x0}; + const char str[] = BLI_STR_UTF8_OPTION_KEY; icon_draw_rect_input_text(&rect, color, str, 13.0f, 0.0f); } else { @@ -102,11 +102,11 @@ void icon_draw_rect_input( } else if (event_type == EVT_OSKEY) { if (platform == MACOS) { - const char str[] = {0xe2, 0x8c, 0x98, 0x0}; + const char str[] = BLI_STR_UTF8_PLACE_OF_INTEREST_SIGN; icon_draw_rect_input_text(&rect, color, str, 16.0f, 0.0f); } else if (platform == MSWIN) { - const char str[] = {0xe2, 0x9d, 0x96, 0x0}; + const char str[] = BLI_STR_UTF8_BLACK_DIAMOND_MINUS_WHITE_X; icon_draw_rect_input_text(&rect, color, str, 16.0f, 0.0f); } else { @@ -117,7 +117,7 @@ void icon_draw_rect_input( icon_draw_rect_input_text(&rect, color, "Del", 9.0f, 0.0f); } else if (event_type == EVT_TABKEY) { - const char str[] = {0xe2, 0xad, 0xbe, 0x0}; + const char str[] = BLI_STR_UTF8_HORIZONTAL_TAB_KEY; icon_draw_rect_input_text(&rect, color, str, 18.0f, -1.5f); } else if (event_type == EVT_HOMEKEY) { @@ -127,12 +127,12 @@ void icon_draw_rect_input( icon_draw_rect_input_text(&rect, color, "End", 8.0f, 0.0f); } else if (event_type == EVT_RETKEY) { - const char str[] = {0xe2, 0x8f, 0x8e, 0x0}; + const char str[] = BLI_STR_UTF8_RETURN_SYMBOL; icon_draw_rect_input_text(&rect, color, str, 17.0f, -1.0f); } else if (event_type == EVT_ESCKEY) { if (platform == MACOS) { - const char str[] = {0xe2, 0x8e, 0x8b, 0x0}; + const char str[] = BLI_STR_UTF8_BROKEN_CIRCLE_WITH_NORTHWEST_ARROW; icon_draw_rect_input_text(&rect, color, str, 21.0f, -1.0f); } else { @@ -140,31 +140,31 @@ void icon_draw_rect_input( } } else if (event_type == EVT_PAGEUPKEY) { - const char str[] = {'P', 0xe2, 0x86, 0x91, 0x0}; + const char str[] = "P" BLI_STR_UTF8_UPWARDS_ARROW; icon_draw_rect_input_text(&rect, color, str, 12.0f, 0.0f); } else if (event_type == EVT_PAGEDOWNKEY) { - const char str[] = {'P', 0xe2, 0x86, 0x93, 0x0}; + const char str[] = "P" BLI_STR_UTF8_DOWNWARDS_ARROW; icon_draw_rect_input_text(&rect, color, str, 12.0f, 0.0f); } else if (event_type == EVT_LEFTARROWKEY) { - const char str[] = {0xe2, 0x86, 0x90, 0x0}; + const char str[] = BLI_STR_UTF8_LEFTWARDS_ARROW; icon_draw_rect_input_text(&rect, color, str, 18.0f, -1.5f); } else if (event_type == EVT_UPARROWKEY) { - const char str[] = {0xe2, 0x86, 0x91, 0x0}; + const char str[] = BLI_STR_UTF8_UPWARDS_ARROW; icon_draw_rect_input_text(&rect, color, str, 16.0f, 0.0f); } else if (event_type == EVT_RIGHTARROWKEY) { - const char str[] = {0xe2, 0x86, 0x92, 0x0}; + const char str[] = BLI_STR_UTF8_RIGHTWARDS_ARROW; icon_draw_rect_input_text(&rect, color, str, 18.0f, -1.5f); } else if (event_type == EVT_DOWNARROWKEY) { - const char str[] = {0xe2, 0x86, 0x93, 0x0}; + const char str[] = BLI_STR_UTF8_DOWNWARDS_ARROW; icon_draw_rect_input_text(&rect, color, str, 16.0f, 0.0f); } else if (event_type == EVT_SPACEKEY) { - const char str[] = {0xe2, 0x90, 0xa3, 0x0}; + const char str[] = BLI_STR_UTF8_OPEN_BOX; icon_draw_rect_input_text(&rect, color, str, 20.0f, 2.0f); } } diff --git a/source/blender/editors/interface/interface_widgets.cc b/source/blender/editors/interface/interface_widgets.cc index d6e1b395718..83ccdd1e4a6 100644 --- a/source/blender/editors/interface/interface_widgets.cc +++ b/source/blender/editors/interface/interface_widgets.cc @@ -1538,8 +1538,7 @@ float UI_text_clip_middle_ex(const uiFontStyle *fstyle, float strwidth = BLF_width(fstyle->uifont_id, str, max_len); if ((okwidth > 0.0f) && (strwidth > okwidth)) { - /* Ellipsis. Some compilers complain with real literal string. */ - const char sep[] = {0xe2, 0x80, 0xA6, 0x0}; + const char sep[] = BLI_STR_UTF8_HORIZONTAL_ELLIPSIS; const int sep_len = sizeof(sep) - 1; const float sep_strwidth = BLF_width(fstyle->uifont_id, sep, sep_len + 1); diff --git a/source/blender/editors/space_sequencer/sequencer_edit.cc b/source/blender/editors/space_sequencer/sequencer_edit.cc index 84f506ff006..496a455aace 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.cc +++ b/source/blender/editors/space_sequencer/sequencer_edit.cc @@ -2741,9 +2741,9 @@ void SEQUENCER_OT_swap_data(wmOperatorType *ot) * \{ */ static const EnumPropertyItem prop_change_effect_input_types[] = { - {0, "A_B", 0, "A -> B", ""}, - {1, "B_C", 0, "B -> C", ""}, - {2, "A_C", 0, "A -> C", ""}, + {0, "A_B", 0, "A " BLI_STR_UTF8_RIGHTWARDS_ARROW " B", ""}, + {1, "B_C", 0, "B " BLI_STR_UTF8_RIGHTWARDS_ARROW " C", ""}, + {2, "A_C", 0, "A " BLI_STR_UTF8_RIGHTWARDS_ARROW " C", ""}, {0, nullptr, 0, nullptr, nullptr}, }; diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c index 3eaa9f4f973..7e0fa8fc133 100644 --- a/source/blender/makesrna/intern/rna_wm.c +++ b/source/blender/makesrna/intern/rna_wm.c @@ -13,6 +13,7 @@ #include "DNA_userdef_types.h" #include "DNA_windowmanager_types.h" +#include "BLI_string_utf8_symbols.h" #include "BLI_utildefines.h" #include "BLT_translation.h" @@ -248,10 +249,10 @@ const EnumPropertyItem rna_enum_event_type_items[] = { {EVT_EQUALKEY, "EQUAL", 0, "=", ""}, {EVT_LEFTBRACKETKEY, "LEFT_BRACKET", 0, "[", ""}, {EVT_RIGHTBRACKETKEY, "RIGHT_BRACKET", 0, "]", ""}, - {EVT_LEFTARROWKEY, "LEFT_ARROW", 0, "Left Arrow", "←"}, - {EVT_DOWNARROWKEY, "DOWN_ARROW", 0, "Down Arrow", "↓"}, - {EVT_RIGHTARROWKEY, "RIGHT_ARROW", 0, "Right Arrow", "→"}, - {EVT_UPARROWKEY, "UP_ARROW", 0, "Up Arrow", "↑"}, + {EVT_LEFTARROWKEY, "LEFT_ARROW", 0, "Left Arrow", BLI_STR_UTF8_LEFTWARDS_ARROW}, + {EVT_DOWNARROWKEY, "DOWN_ARROW", 0, "Down Arrow", BLI_STR_UTF8_DOWNWARDS_ARROW}, + {EVT_RIGHTARROWKEY, "RIGHT_ARROW", 0, "Right Arrow", BLI_STR_UTF8_RIGHTWARDS_ARROW}, + {EVT_UPARROWKEY, "UP_ARROW", 0, "Up Arrow", BLI_STR_UTF8_UPWARDS_ARROW}, {EVT_PAD2, "NUMPAD_2", 0, "Numpad 2", "Pad2"}, {EVT_PAD4, "NUMPAD_4", 0, "Numpad 4", "Pad4"}, {EVT_PAD6, "NUMPAD_6", 0, "Numpad 6", "Pad6"}, @@ -299,10 +300,22 @@ const EnumPropertyItem rna_enum_event_type_items[] = { {EVT_PAGEDOWNKEY, "PAGE_DOWN", 0, "Page Down", "PgDown"}, {EVT_ENDKEY, "END", 0, "End", ""}, RNA_ENUM_ITEM_SEPR, - {EVT_MEDIAPLAY, "MEDIA_PLAY", 0, "Media Play/Pause", ">/||"}, - {EVT_MEDIASTOP, "MEDIA_STOP", 0, "Media Stop", "Stop"}, - {EVT_MEDIAFIRST, "MEDIA_FIRST", 0, "Media First", "|<<"}, - {EVT_MEDIALAST, "MEDIA_LAST", 0, "Media Last", ">>|"}, + {EVT_MEDIAPLAY, + "MEDIA_PLAY", + 0, + "Media Play/Pause", + BLI_STR_UTF8_BLACK_RIGHT_POINTING_TRIANGLE_WITH_DOUBLE_VERTICAL_BAR}, + {EVT_MEDIASTOP, "MEDIA_STOP", 0, "Media Stop", BLI_STR_UTF8_BLACK_SQUARE_FOR_STOP}, + {EVT_MEDIAFIRST, + "MEDIA_FIRST", + 0, + "Media First", + BLI_STR_UTF8_BLACK_LEFT_POINTING_DOUBLE_TRIANGLE_WITH_VERTICAL_BAR}, + {EVT_MEDIALAST, + "MEDIA_LAST", + 0, + "Media Last", + BLI_STR_UTF8_BLACK_RIGHT_POINTING_DOUBLE_TRIANGLE_WITH_VERTICAL_BAR}, RNA_ENUM_ITEM_SEPR, {KM_TEXTINPUT, "TEXTINPUT", 0, "Text Input", "TxtIn"}, RNA_ENUM_ITEM_SEPR, @@ -321,10 +334,18 @@ const EnumPropertyItem rna_enum_event_type_items[] = { {NDOF_BUTTON_MENU, "NDOF_BUTTON_MENU", 0, "NDOF Menu", "NdofMenu"}, {NDOF_BUTTON_FIT, "NDOF_BUTTON_FIT", 0, "NDOF Fit", "NdofFit"}, /* view buttons */ - {NDOF_BUTTON_TOP, "NDOF_BUTTON_TOP", 0, "NDOF Top", "Ndof↑"}, - {NDOF_BUTTON_BOTTOM, "NDOF_BUTTON_BOTTOM", 0, "NDOF Bottom", "Ndof↓"}, - {NDOF_BUTTON_LEFT, "NDOF_BUTTON_LEFT", 0, "NDOF Left", "Ndof←"}, - {NDOF_BUTTON_RIGHT, "NDOF_BUTTON_RIGHT", 0, "NDOF Right", "Ndof→"}, + {NDOF_BUTTON_TOP, "NDOF_BUTTON_TOP", 0, "NDOF Top", "Ndof" BLI_STR_UTF8_UPWARDS_ARROW}, + {NDOF_BUTTON_BOTTOM, + "NDOF_BUTTON_BOTTOM", + 0, + "NDOF Bottom", + "Ndof" BLI_STR_UTF8_DOWNWARDS_ARROW}, + {NDOF_BUTTON_LEFT, "NDOF_BUTTON_LEFT", 0, "NDOF Left", "Ndof" BLI_STR_UTF8_LEFTWARDS_ARROW}, + {NDOF_BUTTON_RIGHT, + "NDOF_BUTTON_RIGHT", + 0, + "NDOF Right", + "Ndof" BLI_STR_UTF8_RIGHTWARDS_ARROW}, {NDOF_BUTTON_FRONT, "NDOF_BUTTON_FRONT", 0, "NDOF Front", "NdofFront"}, {NDOF_BUTTON_BACK, "NDOF_BUTTON_BACK", 0, "NDOF Back", "NdofBack"}, /* more views */ diff --git a/source/blender/windowmanager/intern/wm_keymap.c b/source/blender/windowmanager/intern/wm_keymap.c index 52c94b32224..7a4e0f96dfc 100644 --- a/source/blender/windowmanager/intern/wm_keymap.c +++ b/source/blender/windowmanager/intern/wm_keymap.c @@ -1072,7 +1072,7 @@ const char *WM_key_event_string(const short type, const bool compact) case EVT_LEFTSHIFTKEY: case EVT_RIGHTSHIFTKEY: { if (platform == MACOS) { - single_glyph = "\xe2\x87\xa7"; + single_glyph = BLI_STR_UTF8_UPWARDS_WHITE_ARROW; } return key_event_glyph_or_text( font_id, CTX_IFACE_(BLT_I18NCONTEXT_ID_WINDOWMANAGER, "Shift"), single_glyph); @@ -1080,48 +1080,50 @@ const char *WM_key_event_string(const short type, const bool compact) case EVT_LEFTCTRLKEY: case EVT_RIGHTCTRLKEY: if (platform == MACOS) { - return key_event_glyph_or_text(font_id, "^", "\xe2\x8c\x83"); + return key_event_glyph_or_text(font_id, "^", BLI_STR_UTF8_UP_ARROWHEAD); } return IFACE_("Ctrl"); case EVT_LEFTALTKEY: case EVT_RIGHTALTKEY: { if (platform == MACOS) { /* Option symbol on Mac keyboard. */ - single_glyph = "\xe2\x8c\xa5"; + single_glyph = BLI_STR_UTF8_OPTION_KEY; } return key_event_glyph_or_text(font_id, IFACE_("Alt"), single_glyph); } case EVT_OSKEY: { if (platform == MACOS) { - return key_event_glyph_or_text(font_id, IFACE_("Cmd"), "\xe2\x8c\x98"); + return key_event_glyph_or_text( + font_id, IFACE_("Cmd"), BLI_STR_UTF8_PLACE_OF_INTEREST_SIGN); } if (platform == MSWIN) { - return key_event_glyph_or_text(font_id, IFACE_("Win"), "\xe2\x9d\x96"); + return key_event_glyph_or_text( + font_id, IFACE_("Win"), BLI_STR_UTF8_BLACK_DIAMOND_MINUS_WHITE_X); } return IFACE_("OS"); } break; case EVT_TABKEY: return key_event_glyph_or_text( - font_id, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Tab"), "\xe2\xad\xbe"); + font_id, CTX_N_(BLT_I18NCONTEXT_UI_EVENTS, "Tab"), BLI_STR_UTF8_HORIZONTAL_TAB_KEY); case EVT_BACKSPACEKEY: - return key_event_glyph_or_text(font_id, IFACE_("Bksp"), "\xe2\x8c\xab"); + return key_event_glyph_or_text(font_id, IFACE_("Bksp"), BLI_STR_UTF8_ERASE_TO_THE_LEFT); case EVT_ESCKEY: if (platform == MACOS) { - single_glyph = "\xe2\x8e\x8b"; + single_glyph = BLI_STR_UTF8_BROKEN_CIRCLE_WITH_NORTHWEST_ARROW; } return key_event_glyph_or_text(font_id, IFACE_("Esc"), single_glyph); case EVT_RETKEY: - return key_event_glyph_or_text(font_id, IFACE_("Enter"), "\xe2\x86\xb5"); + return key_event_glyph_or_text(font_id, IFACE_("Enter"), BLI_STR_UTF8_RETURN_SYMBOL); case EVT_SPACEKEY: - return key_event_glyph_or_text(font_id, IFACE_("Space"), "\xe2\x90\xa3"); + return key_event_glyph_or_text(font_id, IFACE_("Space"), BLI_STR_UTF8_OPEN_BOX); case EVT_LEFTARROWKEY: - return key_event_glyph_or_text(font_id, IFACE_("Left"), "\xe2\x86\x90"); + return key_event_glyph_or_text(font_id, IFACE_("Left"), BLI_STR_UTF8_LEFTWARDS_ARROW); case EVT_UPARROWKEY: - return key_event_glyph_or_text(font_id, IFACE_("Up"), "\xe2\x86\x91"); + return key_event_glyph_or_text(font_id, IFACE_("Up"), BLI_STR_UTF8_UPWARDS_ARROW); case EVT_RIGHTARROWKEY: - return key_event_glyph_or_text(font_id, IFACE_("Right"), "\xe2\x86\x92"); + return key_event_glyph_or_text(font_id, IFACE_("Right"), BLI_STR_UTF8_RIGHTWARDS_ARROW); case EVT_DOWNARROWKEY: - return key_event_glyph_or_text(font_id, IFACE_("Down"), "\xe2\x86\x93"); + return key_event_glyph_or_text(font_id, IFACE_("Down"), BLI_STR_UTF8_DOWNWARDS_ARROW); } } -- 2.30.2 From 335bf9222e873a50fd6fdf032ba36b12fa93c27f Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Sun, 25 Jun 2023 20:17:54 -0700 Subject: [PATCH 2/2] Removing UTF32 defines --- source/blender/blenlib/BLI_string_utf8_symbols.h | 7 ------- source/blender/blenlib/intern/string_search.cc | 6 +++--- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/source/blender/blenlib/BLI_string_utf8_symbols.h b/source/blender/blenlib/BLI_string_utf8_symbols.h index dd75f23a859..e180e0a38b3 100644 --- a/source/blender/blenlib/BLI_string_utf8_symbols.h +++ b/source/blender/blenlib/BLI_string_utf8_symbols.h @@ -39,13 +39,6 @@ extern "C" { #define BLI_STR_UTF8_HORIZONTAL_TAB_KEY u8"\u2B7E" /* ⭾ */ #define BLI_STR_UTF8_BLACK_DIAMOND_MINUS_WHITE_X u8"\u2756" /* ❖ */ -/* Unicode characters as UTF-32 codepoints. Last portion should include the official assigned name. - * Please do not add defines here that are not actually in use. */ - -#define BLI_STR_UTF32_SPACE U'\u0020' /* */ -#define BLI_STR_UTF32_SLASH U'\u002F' /* / */ -#define BLI_STR_UTF32_BLACK_RIGHT_POINTING_SMALL_TRIANGLE U'\u25B8' /* ▸ */ - #ifdef __cplusplus } #endif diff --git a/source/blender/blenlib/intern/string_search.cc b/source/blender/blenlib/intern/string_search.cc index 80448f24a3e..89e6ba58be6 100644 --- a/source/blender/blenlib/intern/string_search.cc +++ b/source/blender/blenlib/intern/string_search.cc @@ -15,7 +15,7 @@ /* Right arrow, keep in sync with #UI_MENU_ARROW_SEP in `UI_interface.h`. */ #define UI_MENU_ARROW_SEP BLI_STR_UTF8_BLACK_RIGHT_POINTING_SMALL_TRIANGLE -#define UI_MENU_ARROW_SEP_UNICODE BLI_STR_UTF32_BLACK_RIGHT_POINTING_SMALL_TRIANGLE +#define UI_MENU_ARROW_SEP_UNICODE 0x25b8 namespace blender::string_search { @@ -348,8 +348,8 @@ void extract_normalized_words(StringRef str, LinearAllocator<> &allocator, Vector &r_words) { - const uint32_t unicode_space = BLI_STR_UTF32_SPACE; - const uint32_t unicode_slash = BLI_STR_UTF32_SLASH; + const uint32_t unicode_space = uint32_t(' '); + const uint32_t unicode_slash = uint32_t('/'); const uint32_t unicode_right_triangle = UI_MENU_ARROW_SEP_UNICODE; BLI_assert(unicode_space == BLI_str_utf8_as_unicode(" ")); -- 2.30.2