Qsmtp  0.37
Functions
utf8.c File Reference

UTF-8 processing functions. More...

#include <qutf8.h>
#include <stdbool.h>

Functions

static bool utf8_tail (unsigned char c)
 
static int utf8_2_start (unsigned char c)
 check if this is the beginning of an UTF8-2 sequence More...
 
static int utf8_3_start (unsigned char ch1, unsigned char ch2)
 check if this is the beginning of an UTF8-3 sequence More...
 
static int utf8_4_start (unsigned char ch1, unsigned char ch2)
 check if this is the beginning of an UTF8-4 sequence More...
 
int valid_utf8 (const cstring s)
 check if a given string contains only valid UTF-8 sequences More...
 

Detailed Description

UTF-8 processing functions.

Function Documentation

◆ utf8_2_start()

static int utf8_2_start ( unsigned char  c)
static

check if this is the beginning of an UTF8-2 sequence

Returns
the number of UTF8-tail bytes expected)
Return values
0this is no UTF8-4 sequence

◆ utf8_3_start()

static int utf8_3_start ( unsigned char  ch1,
unsigned char  ch2 
)
static

check if this is the beginning of an UTF8-3 sequence

Returns
the number of UTF8-tail bytes expected)
Return values
0this is no UTF8-3 sequence

◆ utf8_4_start()

static int utf8_4_start ( unsigned char  ch1,
unsigned char  ch2 
)
static

check if this is the beginning of an UTF8-4 sequence

Returns
the number of UTF8-tail bytes expected)
Return values
0this is no UTF8-4 sequence

◆ valid_utf8()

int valid_utf8 ( const cstring  s)

check if a given string contains only valid UTF-8 sequences

Parameters
sstring to check
Returns
the number of UTF-8 characters in s
Return values
-1the sequence is invalid