libcommonc++  0.7
UTF8Encoder Class Reference

A UTF-16 to UTF-8 string transcoder. More...

#include <UTF8Encoder.h++>

Public Member Functions

 UTF8Encoder ()
 Construct a new UTF8Encoder. More...
 
 ~UTF8Encoder ()
 Destructor. More...
 
int encode (const char16_t **input, int *inputCountLeft, char **output, int *outputCountLeft)
 Transcode UTF-16 data ot UTF-8. More...
 
void reset ()
 

Static Public Member Functions

static int encodedLength (const char16_t *input, int length, int maxLength=0)
 Calculate the transcoded length of the UTF-8 data, without actually transcoding the string. More...
 

Static Public Attributes

static const int STATUS_OK = 0
 A status indicating that all input has been successfully transcoded. More...
 
static const int STATUS_NEED_MORE_INPUT = -1
 A status indicating that more input must be supplied to complete the transcoding. More...
 
static const int STATUS_OUTPUT_BUFFER_FULL = -2
 A status indicating that there is not enough room in the output buffer to finish transcoding the input buffer. More...
 
static const int STATUS_INVALID_INPUT = -3
 A status indicating that transcoding cannot continue because invalid data was encountered in the input buffer. More...
 

Detailed Description

A UTF-16 to UTF-8 string transcoder.

Since the String class provides facilities for converting text to/from UTF-8, this class will generally not need to be used directly.

Author
Mark Lindner

Constructor & Destructor Documentation

◆ UTF8Encoder()

Construct a new UTF8Encoder.

◆ ~UTF8Encoder()

Destructor.

Member Function Documentation

◆ encode()

int encode ( const char16_t **  input,
int *  inputCountLeft,
char **  output,
int *  outputCountLeft 
)

Transcode UTF-16 data ot UTF-8.

Parameters
inputA pointer to a pointer to the input buffer containing the UTF-16 data. On return, the pointer will be incremented by the number of UTF-16 code points consumed from input.
inputCountLeftA pointer to the number of UTF-16 code points remaining to be decoded from input. On return, the value will be decremented by the number of UTF-16 code point consumed from input.
outputA pointer to a pointer to the output buffer where the UTF-8 data will be written. On return, the pointer will be incremented by the number of characters written to output.
outputCountLeftA pointer to the number of characters remaining in output. On return, the value will be decremented by the number of characters that were written to output.
Returns
One of the status constants defined in UTFDecoder.

◆ encodedLength()

int encodedLength ( const char16_t input,
int  length,
int  maxLength = 0 
)
static

Calculate the transcoded length of the UTF-8 data, without actually transcoding the string.

Returns
The decoded length of the UTF-8 string, in bytes, or -1 if the input is invalid.

◆ reset()

void reset ( )

Member Data Documentation

◆ STATUS_INVALID_INPUT

const int STATUS_INVALID_INPUT = -3
static

A status indicating that transcoding cannot continue because invalid data was encountered in the input buffer.

◆ STATUS_NEED_MORE_INPUT

const int STATUS_NEED_MORE_INPUT = -1
static

A status indicating that more input must be supplied to complete the transcoding.

◆ STATUS_OK

const int STATUS_OK = 0
static

A status indicating that all input has been successfully transcoded.

◆ STATUS_OUTPUT_BUFFER_FULL

const int STATUS_OUTPUT_BUFFER_FULL = -2
static

A status indicating that there is not enough room in the output buffer to finish transcoding the input buffer.


The documentation for this class was generated from the following files: