Blender V2.61 - r43446
Defines | Functions

BLI_string_utf8.h File Reference

Go to the source code of this file.

Defines

#define BLI_UTF8_MAX   6
#define BLI_UTF8_ERR   ((unsigned int)-1)

Functions

char * BLI_strncpy_utf8 (char *dst, const char *src, size_t maxncpy)
char * BLI_strncat_utf8 (char *dst, const char *src, size_t maxncpy)
int BLI_utf8_invalid_byte (const char *str, int length)
int BLI_utf8_invalid_strip (char *str, int length)
int BLI_str_utf8_size (const char *p)
unsigned int BLI_str_utf8_as_unicode (const char *p)
unsigned int BLI_str_utf8_as_unicode_and_size (const char *p, size_t *index)
unsigned int BLI_str_utf8_as_unicode_step (const char *p, size_t *index)
size_t BLI_str_utf8_from_unicode (unsigned int c, char *outbuf)
char * BLI_str_find_prev_char_utf8 (const char *str, const char *p)
char * BLI_str_find_next_char_utf8 (const char *p, const char *end)
char * BLI_str_prev_char_utf8 (const char *p)
size_t BLI_wstrlen_utf8 (const wchar_t *src)
size_t BLI_strlen_utf8 (const char *strc)
size_t BLI_strncpy_wchar_as_utf8 (char *dst, const wchar_t *src, const size_t maxcpy)
size_t BLI_strncpy_wchar_from_utf8 (wchar_t *dst, const char *src, const size_t maxcpy)

Detailed Description

Definition in file BLI_string_utf8.h.


Define Documentation

#define BLI_UTF8_ERR   ((unsigned int)-1)
#define BLI_UTF8_MAX   6

Function Documentation

char* BLI_str_find_next_char_utf8 ( const char *  p,
const char *  end 
)

BLI_str_find_next_char_utf8: : a pointer to a position within a UTF-8 encoded string : 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 .

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 528 of file string_utf8.c.

References NULL, and p.

Referenced by BLI_str_utf8_as_unicode_step(), BLI_strncpy_wchar_from_utf8(), and ui_textedit_step_next_utf8().

char* BLI_str_find_prev_char_utf8 ( const char *  str,
const char *  p 
)

BLI_str_find_prev_char_utf8: : pointer to the beginning of a UTF-8 encoded string : pointer to some position within

Given a position with a UTF-8 encoded string , find the start of the previous UTF-8 character starting before . Returns NULL if no UTF-8 characters are present in before .

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 503 of file string_utf8.c.

References NULL, p, and str.

Referenced by ui_textedit_step_prev_utf8().

char* BLI_str_prev_char_utf8 ( const char *  p)

BLI_str_prev_char_utf8: : a pointer to a position within a UTF-8 encoded string

Finds the previous UTF-8 character in the string before .

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 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 559 of file string_utf8.c.

References p.

Referenced by draw_brackets(), txt_backspace_char(), txt_jump_left(), txt_move_left(), and txt_wrap_move_eol().

unsigned int BLI_str_utf8_as_unicode ( const char *  p)

BLI_str_utf8_as_unicode: : a pointer to Unicode character encoded as UTF-8

Converts a sequence of bytes encoded as UTF-8 to a Unicode character. If 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 358 of file string_utf8.c.

References BLI_UTF8_ERR, i, len(), UTF8_COMPUTE, and UTF8_GET.

Referenced by txt_jump_left(), txt_jump_right(), txt_redo_read_unicode(), and txt_undo_read_unicode().

unsigned int BLI_str_utf8_as_unicode_and_size ( const char *  p,
size_t *  index 
)
unsigned int BLI_str_utf8_as_unicode_step ( const char *  p,
size_t *  index 
)

Definition at line 389 of file string_utf8.c.

References BLI_str_find_next_char_utf8(), BLI_UTF8_ERR, i, len(), NULL, p, UTF8_COMPUTE, and UTF8_GET.

Referenced by text_insert_exec(), and txt_insert_buf().

size_t BLI_str_utf8_from_unicode ( unsigned int  c,
char *  outbuf 
)

BLI_str_utf8_from_unicode: : a Unicode character code : 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 .

Converts a single character to UTF-8.

Return value: number of bytes written

Definition at line 444 of file string_utf8.c.

References i, and len().

Referenced by BLI_strncpy_wchar_as_utf8(), BLI_wstrlen_utf8(), text_insert_invoke(), txt_add_char_intern(), txt_extended_ascii_as_utf8(), txt_print_undo(), txt_replace_char(), and txt_undo_add_charop().

int BLI_str_utf8_size ( const char *  p)
size_t BLI_strlen_utf8 ( const char *  strc)

Definition at line 235 of file string_utf8.c.

References len().

Referenced by BKE_text_to_curve(), and insert_text_exec().

char* BLI_strncat_utf8 ( char *  dst,
const char *  src,
size_t  maxncpy 
)

Definition at line 193 of file string_utf8.c.

References BLI_STR_UTF8_CPY.

Referenced by BLI_uniquename_cb().

char* BLI_strncpy_utf8 ( char *  dst,
const char *  src,
size_t  maxncpy 
)
size_t BLI_strncpy_wchar_as_utf8 ( char *  dst,
const wchar_t *  src,
const size_t  maxcpy 
)

Definition at line 210 of file string_utf8.c.

References BLI_str_utf8_from_unicode(), and len().

Referenced by insert_text_invoke(), and update_string().

size_t BLI_strncpy_wchar_from_utf8 ( wchar_t *  dst,
const char *  src,
const size_t  maxcpy 
)
int BLI_utf8_invalid_byte ( const char *  str,
int  length 
)

Definition at line 59 of file string_utf8.c.

References p, str, and trailingBytesForUTF8.

Referenced by BLI_utf8_invalid_strip(), and txt_extended_ascii_as_utf8().

int BLI_utf8_invalid_strip ( char *  str,
int  length 
)

Definition at line 125 of file string_utf8.c.

References BLI_utf8_invalid_byte().

Referenced by new_id(), and ui_textedit_end().

size_t BLI_wstrlen_utf8 ( const wchar_t *  src)

Definition at line 223 of file string_utf8.c.

References BLI_str_utf8_from_unicode(), len(), and NULL.

Referenced by update_string().