14#ifndef UTILS_GP_UTF_POS_H
15#define UTILS_GP_UTF_POS_H
75 return !str[pos.
bytes];
211 cur_pos->
bytes += chsz;
227 cur_pos->
bytes -= chsz;
Unicode helper macros and functions.
static uint32_t gp_utf8_next(const char **str)
Parses next unicode character in UTF-8 string.
int8_t gp_utf8_prev_chsz(const char *str, size_t off)
Returns number of bytes previous character is occupying in an UTF-8 string.
int8_t gp_utf8_next_chsz(const char *str, size_t off)
Returns number of bytes next character is occupying in an UTF-8 string.
static gp_utf8_pos gp_utf8_pos_add(gp_utf8_pos a, gp_utf8_pos b)
Adds two positions.
static uint32_t gp_utf8_pos_prev(const char *str, gp_utf8_pos *pos)
Moves a single character towards the string start and returns current character.
static gp_utf8_pos gp_utf8_pos_last(const char *str)
Moves the position to the end of the string.
static int gp_utf8_pos_gt(gp_utf8_pos a, gp_utf8_pos b)
Returns true if position a is greater than position b.
static int gp_utf8_pos_eq(gp_utf8_pos a, gp_utf8_pos b)
Returns true if two positions are equal.
static int gp_utf8_pos_at_home(gp_utf8_pos pos)
Returns true if the position points to the start of the string.
static ssize_t gp_utf8_pos_move(const char *str, gp_utf8_pos *cur_pos, ssize_t dir)
Moves a position in a string by dir characters.
static uint32_t gp_utf8_pos_next(const char *str, gp_utf8_pos *pos)
Moves a single character towards the string end and returns current character.
static int gp_utf8_pos_at_end(const char *str, gp_utf8_pos pos)
Returns true if the position points to the end of the string.
static gp_utf8_pos gp_utf8_pos_first(void)
Moves the position to the start of the string.
static int gp_utf8_pos_ge(gp_utf8_pos a, gp_utf8_pos b)
Returns true if position a is greater or equal to position b.
static gp_utf8_pos gp_utf8_pos_sub(gp_utf8_pos a, gp_utf8_pos b)
Substracts two positions.
static gp_utf8_pos gp_utf8_pos_max(gp_utf8_pos a, gp_utf8_pos b)
Returns bigger of two positions.
static gp_utf8_pos gp_utf8_pos_min(gp_utf8_pos a, gp_utf8_pos b)
Returns smaller of two positions.
Position in an UTF-8 string.