utf-8.c File Reference

Functions for checking that strings contain UTF-8 characters only. More...

#include "utf-8.h"
#include <stdlib.h>
#include <string.h>
#include "StackTrace.h"
Include dependency graph for utf-8.c:

Functions

static const char * UTF8_char_validate (int len, const char *data)
 Validate a single UTF-8 character.
int UTF8_validate (int len, const char *data)
 Validate a length-delimited string has only UTF-8 characters.
int UTF8_validateString (const char *string)
 Validate a null-terminated string has only UTF-8 characters.

Variables

struct {
   int   len
 number of elements in the following array (1 to 4)
   struct {
      char   lower
 lower limit of valid range
      char   upper
 upper limit of valid range
   }   bytes [4]
 up to 4 bytes can be used per character
valid_ranges []
 Macro to determine the number of elements in a single-dimension array.

Detailed Description

Functions for checking that strings contain UTF-8 characters only.

See page 104 of the Unicode Standard 5.0 for the list of well formed UTF-8 byte sequences.


Function Documentation

static const char * UTF8_char_validate ( int  len,
const char *  data 
) [static]

Validate a single UTF-8 character.

Parameters:
len the length of the string in "data"
data the bytes to check for a valid UTF-8 char
Returns:
pointer to the start of the next UTF-8 character in "data"
int UTF8_validate ( int  len,
const char *  data 
)

Validate a length-delimited string has only UTF-8 characters.

Parameters:
len the length of the string in "data"
data the bytes to check for valid UTF-8 characters
Returns:
1 (true) if the string has only UTF-8 characters, 0 (false) otherwise

Here is the call graph for this function:

int UTF8_validateString ( const char *  string  ) 

Validate a null-terminated string has only UTF-8 characters.

Parameters:
string the string to check for valid UTF-8 characters
Returns:
1 (true) if the string has only UTF-8 characters, 0 (false) otherwise

Here is the call graph for this function:


Variable Documentation

struct { ... } valid_ranges[]

Macro to determine the number of elements in a single-dimension array.

Structure to hold the valid ranges of UTF-8 characters, for each byte up to 4

 All Data Structures Files Functions Variables Typedefs Defines

Generated on 2 Jun 2018 for MQTT C Client Libraries Internals by  doxygen 1.6.1