|
Blender
V2.93
|
Go to the source code of this file.
Macros | |
| #define | BLI_UTF8_MAX 6 /* mem */ |
| #define | BLI_UTF8_WIDTH_MAX 2 /* columns */ |
| #define | BLI_UTF8_ERR ((unsigned int)-1) |
String Copy/Format Macros | |
Avoid repeating destination with
| |
| #define | STRNCPY_UTF8(dst, src) BLI_strncpy_utf8(dst, src, ARRAY_SIZE(dst)) |
| #define | STRNCPY_UTF8_RLEN(dst, src) BLI_strncpy_utf8_rlen(dst, src, ARRAY_SIZE(dst)) |
Functions | |
| char * | BLI_strncpy_utf8 (char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL() |
| size_t | BLI_strncpy_utf8_rlen (char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL() |
| ptrdiff_t | BLI_utf8_invalid_byte (const char *str, size_t length) ATTR_NONNULL() |
| int | BLI_utf8_invalid_strip (char *str, size_t length) ATTR_NONNULL() |
| int | BLI_str_utf8_size (const char *p) ATTR_NONNULL() |
| int | BLI_str_utf8_size_safe (const char *p) ATTR_NONNULL() |
| unsigned int | BLI_str_utf8_as_unicode (const char *p) ATTR_NONNULL() |
| unsigned int | BLI_str_utf8_as_unicode_and_size (const char *__restrict p, size_t *__restrict index) ATTR_NONNULL() |
| unsigned int | BLI_str_utf8_as_unicode_and_size_safe (const char *__restrict p, size_t *__restrict index) ATTR_NONNULL() |
| unsigned int | BLI_str_utf8_as_unicode_step (const char *__restrict p, size_t *__restrict index) ATTR_NONNULL() |
| size_t | BLI_str_utf8_from_unicode (unsigned int c, char *outbuf) |
| size_t | BLI_str_utf8_as_utf32 (char32_t *__restrict dst_w, const char *__restrict src_c, const size_t maxncpy) ATTR_NONNULL() |
| size_t | BLI_str_utf32_as_utf8 (char *__restrict dst, const char32_t *__restrict src, const size_t maxncpy) ATTR_NONNULL() |
| size_t | BLI_str_utf32_as_utf8_len (const char32_t *src) ATTR_NONNULL() |
| char * | BLI_str_find_prev_char_utf8 (const char *str, const char *p) ATTR_NONNULL() |
| char * | BLI_str_find_next_char_utf8 (const char *p, const char *end) ATTR_NONNULL(1) |
| char * | BLI_str_prev_char_utf8 (const char *p) ATTR_NONNULL() |
| size_t | BLI_wstrlen_utf8 (const wchar_t *src) ATTR_NONNULL() |
| size_t | BLI_strlen_utf8_ex (const char *strc, size_t *r_len_bytes) ATTR_NONNULL() |
| size_t | BLI_strlen_utf8 (const char *strc) ATTR_NONNULL() |
| size_t | BLI_strnlen_utf8_ex (const char *strc, const size_t maxlen, size_t *r_len_bytes) ATTR_NONNULL() |
| size_t | BLI_strnlen_utf8 (const char *strc, const size_t maxlen) ATTR_NONNULL() |
| size_t | BLI_strncpy_wchar_as_utf8 (char *__restrict dst, const wchar_t *__restrict src, const size_t maxncpy) ATTR_NONNULL() |
| size_t | BLI_strncpy_wchar_from_utf8 (wchar_t *__restrict dst, const char *__restrict src, const size_t maxncpy) ATTR_NONNULL() |
| int | BLI_wcwidth (char32_t ucs) |
| int | BLI_wcswidth (const char32_t *pwcs, size_t n) ATTR_NONNULL() |
| int | BLI_str_utf8_char_width (const char *p) ATTR_NONNULL() |
| int | BLI_str_utf8_char_width_safe (const char *p) ATTR_NONNULL() |
| size_t | BLI_str_partition_utf8 (const char *str, const unsigned int delim[], const char **sep, const char **suf) ATTR_NONNULL() |
| size_t | BLI_str_rpartition_utf8 (const char *str, const unsigned int delim[], const char **sep, const char **suf) ATTR_NONNULL() |
| size_t | BLI_str_partition_ex_utf8 (const char *str, const char *end, const unsigned int delim[], const char **sep, const char **suf, const bool from_right) ATTR_NONNULL(1 |
| size_t int | BLI_str_utf8_offset_to_index (const char *str, int offset) |
| int | BLI_str_utf8_offset_from_index (const char *str, int index) |
| int | BLI_str_utf8_offset_to_column (const char *str, int offset) |
| int | BLI_str_utf8_offset_from_column (const char *str, int column) |
| #define BLI_UTF8_ERR ((unsigned int)-1) |
Definition at line 104 of file BLI_string_utf8.h.
| #define BLI_UTF8_MAX 6 /* mem */ |
Definition at line 102 of file BLI_string_utf8.h.
| #define BLI_UTF8_WIDTH_MAX 2 /* columns */ |
Definition at line 103 of file BLI_string_utf8.h.
| #define STRNCPY_UTF8 | ( | dst, | |
| src | |||
| ) | BLI_strncpy_utf8(dst, src, ARRAY_SIZE(dst)) |
Definition at line 111 of file BLI_string_utf8.h.
| #define STRNCPY_UTF8_RLEN | ( | dst, | |
| src | |||
| ) | BLI_strncpy_utf8_rlen(dst, src, ARRAY_SIZE(dst)) |
Definition at line 112 of file BLI_string_utf8.h.
| char* BLI_str_find_next_char_utf8 | ( | const char * | p, |
| const char * | end | ||
| ) |
BLI_str_find_next_char_utf8:
| p | a pointer to a position within a UTF-8 encoded string |
| end | a pointer to the byte following the end of the string, or NULL to indicate that the string is nul-terminated. |
Finds the start of the next UTF-8 character in the string after p
p does not have to be at the beginning of a UTF-8 character. No check is made to see if the character found is actually valid other than it starts with an appropriate byte.
Return value: a pointer to the found character or NULL
Definition at line 807 of file string_utf8.c.
References NULL.
Referenced by BLI_str_cursor_step_next_utf8(), BLI_str_utf8_as_unicode_step(), BLI_str_utf8_as_utf32(), ui_text_clip_give_next_off(), and ui_text_position_from_hidden().
| char* BLI_str_find_prev_char_utf8 | ( | const char * | str, |
| const char * | p | ||
| ) |
BLI_str_find_prev_char_utf8:
| str | pointer to the beginning of a UTF-8 encoded string |
| p | pointer to some position within str |
Given a position p with a UTF-8 encoded string str, find the start of the previous UTF-8 character starting before. p Returns NULL if no UTF-8 characters are present in str before p
p does not have to be at the beginning of a UTF-8 character. No check is made to see if the character found is actually valid other than it starts with an appropriate byte.
Return value: a pointer to the found character or NULL.
Definition at line 782 of file string_utf8.c.
Referenced by blf_font_width_to_rstrlen(), BLI_str_cursor_step_prev_utf8(), BLI_str_partition_ex_utf8(), ui_text_clip_cursor(), ui_text_clip_give_prev_off(), and ui_text_clip_right_label().
| size_t BLI_str_partition_ex_utf8 | ( | const char * | str, |
| const char * | end, | ||
| const unsigned int | delim[], | ||
| const char ** | sep, | ||
| const char ** | suf, | ||
| const bool | from_right | ||
| ) |
Referenced by node_select_grouped_name(), and TEST().
| size_t BLI_str_partition_utf8 | ( | const char * | str, |
| const unsigned int | delim[], | ||
| const char ** | sep, | ||
| const char ** | suf | ||
| ) |
Definition at line 849 of file string_utf8.c.
References BLI_str_partition_ex_utf8(), NULL, and str.
Referenced by TEST().
| char* BLI_str_prev_char_utf8 | ( | const char * | p | ) |
BLI_str_prev_char_utf8:
| p | a pointer to a position within a UTF-8 encoded string |
Finds the previous UTF-8 character in the string before p
p does not have to be at the beginning of a UTF-8 character. No check is made to see if the character found is actually valid other than it starts with an appropriate byte. If p might be the first character of the string, you must use g_utf8_find_prev_char() instead.
Return value: a pointer to the found character.
Definition at line 838 of file string_utf8.c.
Referenced by txt_backspace_char(), txt_move_left(), txt_wrap_move_eol(), and unit_find_str().
| size_t BLI_str_rpartition_utf8 | ( | const char * | str, |
| const unsigned int | delim[], | ||
| const char ** | sep, | ||
| const char ** | suf | ||
| ) |
Definition at line 857 of file string_utf8.c.
References BLI_str_partition_ex_utf8(), NULL, and str.
Referenced by TEST().
| size_t BLI_str_utf32_as_utf8 | ( | char *__restrict | dst, |
| const char32_t *__restrict | src, | ||
| const size_t | maxncpy | ||
| ) |
Definition at line 717 of file string_utf8.c.
References BLI_assert, BLI_str_utf8_from_unicode(), l, len, and t.
Referenced by copy_selection(), ED_curve_editfont_load(), insert_text_invoke(), and paste_text_exec().
| size_t BLI_str_utf32_as_utf8_len | ( | const char32_t * | src | ) |
Definition at line 755 of file string_utf8.c.
References BLI_str_utf8_from_unicode(), len, and NULL.
Referenced by BKE_vfont_clipboard_set(), and ED_curve_editfont_load().
| unsigned int BLI_str_utf8_as_unicode | ( | const char * | p | ) |
BLI_str_utf8_as_unicode:
| p | a pointer to Unicode character encoded as UTF-8 |
Converts a sequence of bytes encoded as UTF-8 to a Unicode character. If p does not point to a valid UTF-8 encoded character, results are undefined. If you are not sure that the bytes are complete valid Unicode characters, you should use g_utf8_get_char_validated() instead.
Return value: the resulting character
Definition at line 533 of file string_utf8.c.
References BLI_UTF8_ERR, Freestyle::c, len, mask(), result, UNLIKELY, UTF8_COMPUTE, and UTF8_GET.
Referenced by BLI_str_partition_ex_utf8(), BLI_str_utf8_char_width(), BLI_str_utf8_char_width_safe(), cursor_delim_type_utf8(), blender::string_search::extract_normalized_words(), blender::string_search::get_fuzzy_match_errors(), insert_text_invoke(), key_event_glyph_or_text(), and text_autocomplete_build().
| unsigned int BLI_str_utf8_as_unicode_and_size | ( | const char *__restrict | p, |
| size_t *__restrict | index | ||
| ) |
Definition at line 550 of file string_utf8.c.
References BLI_UTF8_ERR, Freestyle::c, len, mask(), result, UNLIKELY, UTF8_COMPUTE, and UTF8_GET.
Referenced by BLI_str_partition_ex_utf8(), BLI_str_utf8_as_utf32(), blender::string_search::damerau_levenshtein_distance(), blender::string_search::extract_normalized_words(), blender::string_search::match_word_initials(), txt_backspace_char(), txt_delete_char(), and txt_replace_char().
| unsigned int BLI_str_utf8_as_unicode_and_size_safe | ( | const char *__restrict | p, |
| size_t *__restrict | index | ||
| ) |
Definition at line 566 of file string_utf8.c.
References BLI_UTF8_ERR, Freestyle::c, len, mask(), result, UNLIKELY, UTF8_COMPUTE, and UTF8_GET.
Referenced by text_autocomplete_build().
| unsigned int BLI_str_utf8_as_unicode_step | ( | const char *__restrict | p, |
| size_t *__restrict | index | ||
| ) |
Definition at line 585 of file string_utf8.c.
References BLI_str_find_next_char_utf8(), BLI_UTF8_ERR, Freestyle::c, len, mask(), NULL, result, UNLIKELY, UTF8_COMPUTE, and UTF8_GET.
Referenced by blf_font_count_missing_chars(), text_insert_exec(), and txt_insert_buf().
| size_t BLI_str_utf8_as_utf32 | ( | char32_t *__restrict | dst_w, |
| const char *__restrict | src_c, | ||
| const size_t | maxncpy | ||
| ) |
Definition at line 684 of file string_utf8.c.
References BLI_assert, BLI_str_find_next_char_utf8(), BLI_str_utf8_as_unicode_and_size(), BLI_UTF8_ERR, len, and NULL.
Referenced by BLI_strncpy_wchar_from_utf8(), ED_curve_editfont_make(), font_paste_utf8(), insert_text_exec(), and vfont_to_curve().
| int BLI_str_utf8_char_width | ( | const char * | p | ) |
Definition at line 419 of file string_utf8.c.
References BLI_str_utf8_as_unicode(), BLI_UTF8_ERR, and BLI_wcwidth().
| int BLI_str_utf8_char_width_safe | ( | const char * | p | ) |
Definition at line 429 of file string_utf8.c.
References BLI_str_utf8_as_unicode(), BLI_UTF8_ERR, and BLI_wcwidth().
Referenced by BLI_str_utf8_offset_from_column(), BLI_str_utf8_offset_to_column(), console_cursor_wrap_offset(), flatten_column_to_offset(), flatten_width(), text_cursor_set_to_pos_wrapped(), text_get_cursor_rel(), textview_wrap_offsets(), txt_wrap_move_bol(), and txt_wrap_move_eol().
| size_t BLI_str_utf8_from_unicode | ( | uint | c, |
| char * | outbuf | ||
| ) |
BLI_str_utf8_from_unicode:
| c | a Unicode character code |
| outbuf | output buffer, must have at least 6 bytes of space. If NULL, the length will be computed and returned and nothing will be written to outbuf. |
Converts a single character to UTF-8.
Definition at line 641 of file string_utf8.c.
References Freestyle::c, and len.
Referenced by BLI_str_utf32_as_utf8(), BLI_str_utf32_as_utf8_len(), BLI_strncpy_wchar_as_utf8(), BLI_wstrlen_utf8(), console_insert_invoke(), find_family_object(), text_insert_invoke(), txt_add_char_intern(), txt_extended_ascii_as_utf8(), and txt_replace_char().
| int BLI_str_utf8_offset_from_column | ( | const char * | str, |
| int | column | ||
| ) |
Definition at line 943 of file string_utf8.c.
References BLI_str_utf8_char_width_safe(), BLI_str_utf8_size_safe(), col, pos, and str.
Referenced by textview_draw_string(), txt_move_down(), txt_move_up(), and txt_wrap_move_bol().
| int BLI_str_utf8_offset_from_index | ( | const char * | str, |
| int | index | ||
| ) |
Definition at line 923 of file string_utf8.c.
References BLI_str_utf8_size(), pos, and str.
Referenced by txt_sel_set().
| int BLI_str_utf8_offset_to_column | ( | const char * | str, |
| int | offset | ||
| ) |
Definition at line 933 of file string_utf8.c.
References BLI_str_utf8_char_width_safe(), BLI_str_utf8_size_safe(), pos, and str.
Referenced by textview_draw_sel(), txt_move_down(), and txt_move_up().
| size_t int BLI_str_utf8_offset_to_index | ( | const char * | str, |
| int | offset | ||
| ) |
Definition at line 913 of file string_utf8.c.
References BLI_str_utf8_size(), pos, and str.
| int BLI_str_utf8_size | ( | const char * | p | ) |
Definition at line 495 of file string_utf8.c.
References Freestyle::c, len, mask(), and UTF8_COMPUTE.
Referenced by BLI_str_utf8_offset_from_index(), BLI_str_utf8_offset_to_index(), blender::string_search::get_fuzzy_match_errors(), handleNumInput(), txt_move_right(), ui_do_but_textedit(), ui_text_clip_cursor(), ui_textedit_insert_ascii(), wm_event_add_ghostevent(), and WM_event_print().
| int BLI_str_utf8_size_safe | ( | const char * | p | ) |
Definition at line 508 of file string_utf8.c.
References Freestyle::c, len, mask(), and UTF8_COMPUTE.
Referenced by BLI_str_utf8_offset_from_column(), BLI_str_utf8_offset_to_column(), BLI_strlen_utf8_ex(), BLI_strnlen_utf8_ex(), console_cursor_wrap_offset(), console_insert_invoke(), flatten_column_to_offset(), flatten_string(), flatten_width(), text_convert_whitespace_exec(), text_cursor_set_to_pos_wrapped(), text_font_draw_character_utf8(), text_format_fill(), text_get_cursor_rel(), text_insert_invoke(), textview_wrap_offsets(), txt_wrap_move_bol(), txt_wrap_move_eol(), txtfmt_lua_format_line(), txtfmt_osl_format_line(), txtfmt_pov_format_line(), txtfmt_pov_ini_format_line(), and txtfmt_py_format_line().
| size_t BLI_strlen_utf8 | ( | const char * | strc | ) |
Definition at line 357 of file string_utf8.c.
References BLI_strlen_utf8_ex().
Referenced by blo_do_versions_260(), insert_text_exec(), key_event_glyph_or_text(), radial_control_paint_cursor(), txt_sel_set(), ui_but_text_password_hide(), and voxel_size_edit_draw().
| size_t BLI_strlen_utf8_ex | ( | const char * | strc, |
| size_t * | r_len_bytes | ||
| ) |
Definition at line 344 of file string_utf8.c.
References BLI_str_utf8_size_safe(), and len.
Referenced by BLI_strlen_utf8(), and txt_add_object().
| char* BLI_strncpy_utf8 | ( | char *__restrict | dst, |
| const char *__restrict | src, | ||
| size_t | maxncpy | ||
| ) |
Definition at line 258 of file string_utf8.c.
References BLI_assert, and BLI_STR_UTF8_CPY.
Referenced by apply_unique_name_fn(), arg_handle_engine_set(), BKE_id_attribute_rename(), BKE_preferences_asset_library_name_set(), BKE_view_layer_add(), BKE_view_layer_rename(), ED_object_gpencil_modifier_add(), ED_object_modifier_add(), ED_object_shaderfx_add(), fileselect_ensure_updated_file_params(), make_element_name(), ntreeCompositOutputFileAddSocket(), ntreeCompositOutputFileSetLayer(), ntreeCompositOutputFileSetPath(), seq_add_set_name(), ui_but_anim_expression_create(), ui_but_anim_expression_set(), ui_but_string_get_ex(), ui_but_string_set(), ui_textedit_string_set(), and view_layer_add().
| size_t BLI_strncpy_utf8_rlen | ( | char *__restrict | dst, |
| const char *__restrict | src, | ||
| size_t | maxncpy | ||
| ) |
Definition at line 274 of file string_utf8.c.
References BLI_assert, and BLI_STR_UTF8_CPY.
Referenced by BLI_uniquename_cb(), and WM_keymap_item_raw_to_string().
| size_t BLI_strncpy_wchar_as_utf8 | ( | char *__restrict | dst, |
| const wchar_t *__restrict | src, | ||
| const size_t | maxncpy | ||
| ) |
Definition at line 295 of file string_utf8.c.
References BLI_assert, BLI_str_utf8_from_unicode(), l, len, and t.
Referenced by BKE_appdir_font_folder_default(), BLI_current_working_dir(), and fsmenu_read_system().
| size_t BLI_strncpy_wchar_from_utf8 | ( | wchar_t *__restrict | dst, |
| const char *__restrict | src, | ||
| const size_t | maxncpy | ||
| ) |
Definition at line 393 of file string_utf8.c.
References BLI_str_utf8_as_utf32(), and conv_utf_8_to_16().
Referenced by fsmenu_read_system().
| size_t BLI_strnlen_utf8 | ( | const char * | strc, |
| const size_t | maxlen | ||
| ) |
| strc | the string to measure the length. |
| maxlen | the string length (in bytes) |
Definition at line 387 of file string_utf8.c.
References BLI_strnlen_utf8_ex().
Referenced by blender::string_search::count_utf8_code_points(), and ui_text_position_to_hidden().
| size_t BLI_strnlen_utf8_ex | ( | const char * | strc, |
| const size_t | maxlen, | ||
| size_t * | r_len_bytes | ||
| ) |
Definition at line 363 of file string_utf8.c.
References BLI_str_utf8_size_safe(), and len.
Referenced by BLI_strnlen_utf8(), and ui_textedit_insert_buf().
| ptrdiff_t BLI_utf8_invalid_byte | ( | const char * | str, |
| size_t | length | ||
| ) |
Find first utf-8 invalid byte in given str, of length bytes.
Definition at line 73 of file string_utf8.c.
References Freestyle::c, ELEM, length(), str, and utf8_skip_data.
Referenced by BLI_utf8_invalid_strip(), and txt_extended_ascii_as_utf8().
| int BLI_utf8_invalid_strip | ( | char * | str, |
| size_t | length | ||
| ) |
Remove any invalid utf-8 byte (taking into account multi-bytes sequence of course).
Definition at line 203 of file string_utf8.c.
References BLI_assert, BLI_utf8_invalid_byte(), length(), and str.
Referenced by BKE_id_new_name_validate(), id_name_final_build(), outputNumInput(), seq_add_set_name(), TEST(), ui_textedit_copypaste(), and ui_textedit_end().
| int BLI_wcswidth | ( | const char32_t * | pwcs, |
| size_t | n | ||
| ) |
Definition at line 414 of file string_utf8.c.
| int BLI_wcwidth | ( | char32_t | ucs | ) |
Definition at line 409 of file string_utf8.c.
Referenced by blf_font_draw_mono(), BLI_str_utf8_char_width(), and BLI_str_utf8_char_width_safe().
| size_t BLI_wstrlen_utf8 | ( | const wchar_t * | src | ) |
Definition at line 333 of file string_utf8.c.
References BLI_str_utf8_from_unicode(), len, and NULL.