static inline void encode_simple_cfstring(CFStringRef string, stream_buffer_t *sb) { char *utf8; size_t utf8_length; trait_t trait; trait = trait_string; get_utf8_bytes(string, &utf8, &utf8_length); stream_buffer_write(sb, &trait, sizeof(trait)); stream_buffer_write(sb, &utf8_length, sizeof(utf8_length)); stream_buffer_write(sb, utf8, utf8_length); free(utf8); }
static int calculate_strlen(const char *str) { int i, n = 0; int len = strlen(str); for (i = 0; str[i] != '\0';) { n = get_utf8_bytes(str[i]); if (n > 1) len--; i += n; } return len; }
/* ************************************************************** * the static functions: * * to assist the friso_next finish the work. * ****************************************************************/ __STATIC_API__ size_t read_next_word( friso_task_t task, uint_t * idx, string __word ) { register uint_t t; if ( *idx >= task->length ) { return 0; } task->bytes = get_utf8_bytes( task->text[ *idx ] ); for ( t = 0; t < task->bytes; t++ ) { __word[t] = task->text[ (*idx)++ ]; } __word[t] = '\0'; return task->bytes; }