libguac  0.9.11-incubating
Functions
unicode.h File Reference

Provides functions for manipulating Unicode strings. More...

Go to the source code of this file.

Functions

size_t guac_utf8_charsize (unsigned char c)
 Given the initial byte of a single UTF-8 character, returns the overall byte size of the entire character. More...
 
size_t guac_utf8_strlen (const char *str)
 Given a UTF-8-encoded string, returns the length of the string in characters (not bytes). More...
 
int guac_utf8_write (int codepoint, char *utf8, int length)
 Given destination buffer and its length, writes the given codepoint as UTF-8 to the buffer, returning the number of bytes written. More...
 
int guac_utf8_read (const char *utf8, int length, int *codepoint)
 Given a buffer containing UTF-8 characters, reads the first codepoint in the buffer, returning the length of the codepoint in bytes. More...
 

Detailed Description

Provides functions for manipulating Unicode strings.

Function Documentation

size_t guac_utf8_charsize ( unsigned char  c)

Given the initial byte of a single UTF-8 character, returns the overall byte size of the entire character.

Parameters
cThe initial byte of the character to check.
Returns
The number of bytes in the given character overall.
int guac_utf8_read ( const char *  utf8,
int  length,
int *  codepoint 
)

Given a buffer containing UTF-8 characters, reads the first codepoint in the buffer, returning the length of the codepoint in bytes.

If no codepoint could be read, zero is returned.

Parameters
utf8A buffer containing UTF-8 characters.
lengthThe length of the buffer, in bytes.
codepointA pointer to an integer which will contain the codepoint read, if any. If no character can be read, the integer will be left untouched.
Returns
The number of bytes read, which may be zero if there is not enough space in the buffer to read a character.
size_t guac_utf8_strlen ( const char *  str)

Given a UTF-8-encoded string, returns the length of the string in characters (not bytes).

Parameters
strThe UTF-8 string to calculate the length of.
Returns
The length in characters of the given UTF-8 string.
int guac_utf8_write ( int  codepoint,
char *  utf8,
int  length 
)

Given destination buffer and its length, writes the given codepoint as UTF-8 to the buffer, returning the number of bytes written.

If there is not enough space in the buffer to write the character, no bytes are written at all.

Parameters
codepointThe Unicode codepoint to write to the buffer.
utf8The buffer to write to.
lengthThe length of the buffer, in bytes.
Returns
The number of bytes written, which may be zero if there is not enough space in the buffer to write the UTF-8 character.