Blender
V3.3
|
Go to the source code of this file.
Macros | |
#define | BLI_UTF8_MAX 6 |
#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(1 |
char size_t | BLI_strncpy_utf8_rlen (char *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1 |
char size_t ptrdiff_t | BLI_str_utf8_invalid_byte (const char *str, size_t length) ATTR_NONNULL(1) |
int | BLI_str_utf8_invalid_strip (char *str, size_t length) ATTR_NONNULL(1) |
int | BLI_str_utf8_size (const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) |
int | BLI_str_utf8_size_safe (const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) |
unsigned int | BLI_str_utf8_as_unicode (const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) |
unsigned int | BLI_str_utf8_as_unicode_step (const char *__restrict p, size_t p_len, size_t *__restrict index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1 |
unsigned int unsigned int | BLI_str_utf8_as_unicode_step_or_error (const char *__restrict p, size_t p_len, size_t *__restrict index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1 |
unsigned int unsigned int size_t | BLI_str_utf8_from_unicode_len (unsigned int c) ATTR_WARN_UNUSED_RESULT |
size_t | BLI_str_utf8_from_unicode (unsigned int c, char *outbuf, size_t outbuf_len) ATTR_NONNULL(2) |
size_t | BLI_str_utf8_as_utf32 (char32_t *__restrict dst_w, const char *__restrict src_c, size_t maxncpy) ATTR_NONNULL(1 |
size_t size_t | BLI_str_utf32_as_utf8 (char *__restrict dst, const char32_t *__restrict src, size_t maxncpy) ATTR_NONNULL(1 |
size_t size_t size_t | BLI_str_utf32_as_utf8_len (const char32_t *src) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) |
const char * | BLI_str_find_prev_char_utf8 (const char *p, const char *str_start) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1 |
const char const char * | BLI_str_find_next_char_utf8 (const char *p, const char *str_end) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(1 |
const char const char size_t | BLI_wstrlen_utf8 (const wchar_t *src) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT |
size_t | BLI_strlen_utf8_ex (const char *strc, size_t *r_len_bytes) ATTR_NONNULL(1 |
size_t | BLI_strlen_utf8 (const char *strc) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT |
size_t | BLI_strnlen_utf8_ex (const char *strc, size_t maxlen, size_t *r_len_bytes) ATTR_NONNULL(1 |
size_t size_t | BLI_strnlen_utf8 (const char *strc, size_t maxlen) ATTR_NONNULL(1) ATTR_WARN_UNUSED_RESULT |
size_t | BLI_strncpy_wchar_as_utf8 (char *__restrict dst, const wchar_t *__restrict src, size_t maxncpy) ATTR_NONNULL(1 |
size_t size_t | BLI_strncpy_wchar_from_utf8 (wchar_t *__restrict dst, const char *__restrict src, size_t maxncpy) ATTR_NONNULL(1 |
size_t size_t int | BLI_wcwidth (char32_t ucs) ATTR_WARN_UNUSED_RESULT |
int | BLI_wcswidth (const char32_t *pwcs, size_t n) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) |
int | BLI_str_utf8_char_width (const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) |
int | BLI_str_utf8_char_width_safe (const char *p) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) |
size_t | BLI_str_partition_utf8 (const char *str, const unsigned int delim[], const char **sep, const char **suf) ATTR_NONNULL(1 |
size_t size_t | BLI_str_rpartition_utf8 (const char *str, const unsigned int delim[], const char **sep, const char **suf) ATTR_NONNULL(1 |
size_t size_t size_t | BLI_str_partition_ex_utf8 (const char *str, const char *end, const unsigned int delim[], const char **sep, const char **suf, bool from_right) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1 |
size_t size_t size_t int | BLI_str_utf8_offset_to_index (const char *str, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) |
int | BLI_str_utf8_offset_from_index (const char *str, int index) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) |
int | BLI_str_utf8_offset_to_column (const char *str, int offset) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) |
int | BLI_str_utf8_offset_from_column (const char *str, int column) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) |
Variables | |
size_t | ATTR_WARN_UNUSED_RESULT |
#define BLI_UTF8_ERR ((unsigned int)-1) |
Definition at line 202 of file BLI_string_utf8.h.
#define BLI_UTF8_MAX 6 |
Size in bytes.
Definition at line 200 of file BLI_string_utf8.h.
#define BLI_UTF8_WIDTH_MAX 2 /* columns */ |
Definition at line 201 of file BLI_string_utf8.h.
#define STRNCPY_UTF8 | ( | dst, | |
src | |||
) | BLI_strncpy_utf8(dst, src, ARRAY_SIZE(dst)) |
Definition at line 210 of file BLI_string_utf8.h.
#define STRNCPY_UTF8_RLEN | ( | dst, | |
src | |||
) | BLI_strncpy_utf8_rlen(dst, src, ARRAY_SIZE(dst)) |
Definition at line 211 of file BLI_string_utf8.h.
const char const char* BLI_str_find_next_char_utf8 | ( | const char * | p, |
const char * | str_end | ||
) |
p | a pointer to a position within a UTF-8 encoded string |
str_end | a pointer to the byte following the end of the string. |
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.
Referenced by BLI_str_cursor_step_next_utf8(), ui_text_clip_give_next_off(), and ui_text_position_from_hidden().
const char* BLI_str_find_prev_char_utf8 | ( | const char * | p, |
const char * | str_start | ||
) |
BLI_str_find_prev_char_utf8:
p | pointer to some position within str |
str_start | pointer to the beginning of a UTF-8 encoded string |
Given a position p with a UTF-8 encoded string str, find the start of the previous UTF-8 character starting before. p Returns str_start if no UTF-8 characters are present in str_start 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.
Referenced by blf_font_width_to_rstrlen(), BLI_str_cursor_step_prev_utf8(), text_delete_exec(), txt_backspace_char(), txt_move_left(), txt_wrap_move_eol(), ui_text_clip_cursor(), ui_text_clip_give_prev_off(), ui_text_clip_right_label(), and unit_find_str().
size_t size_t size_t BLI_str_partition_ex_utf8 | ( | const char * | str, |
const char * | end, | ||
const unsigned int | delim[], | ||
const char ** | sep, | ||
const char ** | suf, | ||
bool | from_right | ||
) |
Referenced by blender::ed::space_node::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 | ||
) |
Referenced by TEST().
size_t size_t BLI_str_rpartition_utf8 | ( | const char * | str, |
const unsigned int | delim[], | ||
const char ** | sep, | ||
const char ** | suf | ||
) |
Referenced by TEST().
size_t size_t BLI_str_utf32_as_utf8 | ( | char *__restrict | dst, |
const char32_t *__restrict | src, | ||
size_t | maxncpy | ||
) |
Referenced by copy_selection(), ED_curve_editfont_load(), insert_text_invoke(), and paste_text_exec().
size_t size_t size_t BLI_str_utf32_as_utf8_len | ( | const char32_t * | src | ) |
Definition at line 654 of file string_utf8.c.
References BLI_str_utf8_from_unicode_len(), len, and src.
Referenced by BKE_vfont_clipboard_set(), and ED_curve_editfont_load().
unsigned int BLI_str_utf8_as_unicode | ( | const char * | p | ) |
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 478 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(), blender::string_search::extract_normalized_words(), blender::string_search::get_fuzzy_match_errors(), insert_text_invoke(), key_event_glyph_or_text(), text_autocomplete_build(), and text_insert_invoke().
unsigned int BLI_str_utf8_as_unicode_step | ( | const char *__restrict | p, |
size_t | p_len, | ||
size_t *__restrict | index | ||
) |
UTF8 decoding that steps over the index (unless an error is encountered).
p | The text to step over. |
p_len | The length of p . |
index | Index of p to step over. |
(p + *index)
if there is a decoding error.LATIN1
for text drawing. Referenced by blf_font_count_missing_chars(), blf_glyph_from_utf8_and_step(), blender::string_search::damerau_levenshtein_distance(), blender::string_search::extract_normalized_words(), blender::string_search::match_word_initials(), text_autocomplete_build(), text_insert_exec(), txt_backspace_char(), txt_delete_char(), txt_insert_buf(), txt_replace_char(), and utf8_as_char32().
unsigned int unsigned int BLI_str_utf8_as_unicode_step_or_error | ( | const char *__restrict | p, |
size_t | p_len, | ||
size_t *__restrict | index | ||
) |
UTF8 decoding that steps over the index (unless an error is encountered).
p | The text to step over. |
p_len | The length of p . |
index | Index of p to step over. |
p_len
limits decoding trailing bytes) must have the same behavior is encountering a nil byte, so functions that only use the first part of a string has matching behavior to functions that null terminate the text. Referenced by cursor_delim_type_utf8().
size_t BLI_str_utf8_as_utf32 | ( | char32_t *__restrict | dst_w, |
const char *__restrict | src_c, | ||
size_t | maxncpy | ||
) |
int BLI_str_utf8_char_width | ( | const char * | p | ) |
Definition at line 378 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 388 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 | ( | unsigned int | c, |
char * | outbuf, | ||
size_t | outbuf_len | ||
) |
BLI_str_utf8_from_unicode:
c | a Unicode character code |
outbuf | output buffer, must have at least outbuf_len bytes of space. If the length required by c exceeds outbuf_len , the bytes available bytes will be zeroed and outbuf_len returned. |
Converts a single character to UTF-8.
Definition at line 575 of file string_utf8.c.
References Freestyle::c, len, UNLIKELY, and UTF8_VARS_FROM_CHAR32.
Referenced by BLI_str_utf32_as_utf8(), BLI_strncpy_wchar_as_utf8(), find_family_object(), txt_add_char_intern(), txt_extended_ascii_as_utf8(), txt_replace_char(), and wm_event_add_ghostevent().
unsigned int unsigned int size_t BLI_str_utf8_from_unicode_len | ( | unsigned int | c | ) |
Definition at line 563 of file string_utf8.c.
References Freestyle::c, len, UTF8_VARS_FROM_CHAR32, and void.
Referenced by BLI_str_utf32_as_utf8_len(), and BLI_wstrlen_utf8().
char size_t ptrdiff_t BLI_str_utf8_invalid_byte | ( | const char * | str, |
size_t | length | ||
) |
Find first UTF-8 invalid byte in given str, of length bytes.
Definition at line 46 of file string_utf8.c.
References Freestyle::c, ELEM, blender::math::length(), str, and utf8_skip_data.
Referenced by BLI_str_utf8_invalid_strip(), and txt_extended_ascii_as_utf8().
int BLI_str_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 181 of file string_utf8.c.
References BLI_assert, BLI_str_utf8_invalid_byte(), blender::math::length(), and str.
Referenced by BKE_id_new_name_validate(), id_name_final_build(), objfnt_to_ftvfontdata(), outputNumInput(), SEQ_edit_sequence_name_set(), TEST(), ui_textedit_copypaste(), and ui_textedit_end().
int BLI_str_utf8_offset_from_column | ( | const char * | str, |
int | column | ||
) |
Definition at line 791 of file string_utf8.c.
References BLI_str_utf8_char_width_safe(), BLI_str_utf8_size_safe(), col, offset, 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 771 of file string_utf8.c.
References BLI_str_utf8_size(), offset, pos, and str.
Referenced by blender::nodes::node_fn_slice_string_cc::fn_node_slice_string_build_multi_function(), blender::nodes::node_geo_string_to_curves_cc::get_text_layout(), and txt_sel_set().
int BLI_str_utf8_offset_to_column | ( | const char * | str, |
int | offset | ||
) |
Definition at line 781 of file string_utf8.c.
References BLI_str_utf8_char_width_safe(), BLI_str_utf8_size_safe(), offset, pos, and str.
Referenced by textview_draw_sel(), txt_move_down(), and txt_move_up().
size_t size_t size_t int BLI_str_utf8_offset_to_index | ( | const char * | str, |
int | offset | ||
) |
Definition at line 761 of file string_utf8.c.
References BLI_str_utf8_size(), offset, pos, and str.
int BLI_str_utf8_size | ( | const char * | p | ) |
Definition at line 452 of file string_utf8.c.
References Freestyle::c, len, mask(), UTF8_COMPUTE, and void.
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(), wm_event_add_ghostevent(), WM_event_print(), and WM_event_utf8_to_ascii().
int BLI_str_utf8_size_safe | ( | const char * | p | ) |
Use when we want to skip errors.
Definition at line 466 of file string_utf8.c.
References Freestyle::c, len, mask(), UTF8_COMPUTE, and void.
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_indent_or_autocomplete_exec(), 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 317 of file string_utf8.c.
References BLI_strlen_utf8_ex().
Referenced by blo_do_versions_260(), blender::nodes::node_fn_slice_string_cc::fn_node_slice_string_build_multi_function(), blender::nodes::node_fn_string_length_cc::fn_node_string_length_build_multi_function(), insert_text_exec(), key_event_glyph_or_text(), radial_control_paint_cursor(), blender::io::obj::TEST(), 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 | ||
) |
Referenced by blender::nodes::node_geo_string_to_curves_cc::get_text_layout(), and txt_add_object().
char* BLI_strncpy_utf8 | ( | char *__restrict | dst, |
const char *__restrict | src, | ||
size_t | maxncpy | ||
) |
Referenced by arg_handle_engine_set(), BKE_id_attribute_calc_unique_name(), BKE_id_attribute_rename(), BKE_preferences_asset_library_name_set(), BKE_view_layer_add(), BKE_view_layer_rename(), BKE_view_layer_rename_lightgroup(), ED_object_gpencil_modifier_add(), ED_object_modifier_add(), ED_object_shaderfx_add(), fileselect_ensure_updated_file_params(), make_element_name(), ntreeCompositOutputFileAddSocket(), ntreeCompositOutputFileSetLayer(), ntreeCompositOutputFileSetPath(), proj_paint_add_slot(), SEQ_edit_sequence_name_set(), SEQ_ensure_unique_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().
char size_t BLI_strncpy_utf8_rlen | ( | char *__restrict | dst, |
const char *__restrict | src, | ||
size_t | maxncpy | ||
) |
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, | ||
size_t | maxncpy | ||
) |
Referenced by BKE_appdir_font_folder_default(), BLI_current_working_dir(), and fsmenu_read_system().
size_t size_t BLI_strncpy_wchar_from_utf8 | ( | wchar_t *__restrict | dst, |
const char *__restrict | src, | ||
size_t | maxncpy | ||
) |
Referenced by fsmenu_read_system().
size_t size_t BLI_strnlen_utf8 | ( | const char * | strc, |
size_t | maxlen | ||
) |
strc | the string to measure the length. |
maxlen | the string length (in bytes) |
Definition at line 342 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, |
size_t | maxlen, | ||
size_t * | r_len_bytes | ||
) |
Referenced by ui_textedit_insert_buf().
int BLI_wcswidth | ( | const char32_t * | pwcs, |
size_t | n | ||
) |
Definition at line 373 of file string_utf8.c.
size_t size_t int BLI_wcwidth | ( | char32_t | ucs | ) |
Count columns that character/string occupies (based on wcwidth.co
).
Definition at line 364 of file string_utf8.c.
Referenced by blf_font_draw_mono(), blf_glyph_render(), BLI_str_utf8_char_width(), and BLI_str_utf8_char_width_safe().
const char const char size_t BLI_wstrlen_utf8 | ( | const wchar_t * | src | ) |
wchar_t
length in UTF-8. Definition at line 293 of file string_utf8.c.
References BLI_str_utf8_from_unicode_len(), len, and src.
size_t ATTR_WARN_UNUSED_RESULT |
Definition at line 147 of file BLI_string_utf8.h.