mirror of
https://github.com/rkd77/elinks.git
synced 2024-12-04 14:46:47 -05:00
Added utf8_prevchar for moving throught UTF-8 string to left.
This commit is contained in:
parent
7951d7bf22
commit
9d1008c523
@ -252,6 +252,24 @@ strlen_utf8(unsigned char **str)
|
|||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define utf8_issingle(p) (((p) & 0x80) == 0)
|
||||||
|
#define utf8_islead(p) (utf8_issingle(p) || ((p) & 0xc0) == 0xc0)
|
||||||
|
|
||||||
|
/* Start from @current and move back to @pos char. This pointer return. The
|
||||||
|
* most left pointer is @start. */
|
||||||
|
inline unsigned char *
|
||||||
|
utf8_prevchar(unsigned char *current, int pos, unsigned char *start)
|
||||||
|
{
|
||||||
|
if (current == NULL || start == NULL || pos < 0)
|
||||||
|
return NULL;
|
||||||
|
while (pos > 0 && current != start) {
|
||||||
|
current--;
|
||||||
|
if (utf8_islead(*current))
|
||||||
|
pos--;
|
||||||
|
}
|
||||||
|
return current;
|
||||||
|
}
|
||||||
|
|
||||||
/* Count number of standard terminal cells needed for displaying UTF-8
|
/* Count number of standard terminal cells needed for displaying UTF-8
|
||||||
* character. */
|
* character. */
|
||||||
int
|
int
|
||||||
|
@ -55,6 +55,7 @@ int is_cp_special(int);
|
|||||||
void free_conv_table(void);
|
void free_conv_table(void);
|
||||||
#ifdef CONFIG_UTF_8
|
#ifdef CONFIG_UTF_8
|
||||||
inline unsigned char *encode_utf_8(unicode_val_T);
|
inline unsigned char *encode_utf_8(unicode_val_T);
|
||||||
|
inline unsigned char *utf8_prevchar(unsigned char *, int, unsigned char *);
|
||||||
inline int utf8charlen(const unsigned char *);
|
inline int utf8charlen(const unsigned char *);
|
||||||
int utf8_char2cells(unsigned char *, unsigned char *);
|
int utf8_char2cells(unsigned char *, unsigned char *);
|
||||||
int utf8_ptr2cells(unsigned char *, unsigned char *);
|
int utf8_ptr2cells(unsigned char *, unsigned char *);
|
||||||
|
Loading…
Reference in New Issue
Block a user