Main Page | Class Hierarchy | Class List | Class Members

UTF8 Class Reference

List of all members.

Detailed Description

UTF8 provides static member functions that convert to and from the UTF-8 encoding of Unicode.

Hunny Mail++ functions that accept Unicode text, such as those that accept an IMAP4 mailbox name, require the UTF-8 encoding. Since it is common for Windows applications to represent text in the UTF-16 encoding, the Hunny Mail++ library provides the UTF8 class so that developers can easily convert between UTF-8 and UTF-16.

To understand the naming of the member functions, you should understand the underlying model. In the underlying model, applications process text in the UTF-16 encoding. Therefore, UTF-16 text is considered decoded text. UTF-8 text is considered encoded text.


Static Public Member Functions

size_t EncodeLen (const uint16_t *utf16, size_t utf16Len)
 Gets the length of the UTF-8 string that would result from encoding the UTF-16 string.
size_t Encode (const uint16_t *utf16, size_t utf16Len, char *utf8, size_t utf8MaxLen)
 Converts a UTF-16 string to UTF-8.
size_t DecodeLen (const char *utf8, size_t utf8Len)
 Gets the length of the UTF-16 string that would result from decoding the UTF-8 string.
size_t Decode (const char *utf8, size_t utf8Len, uint16_t *utf16, size_t utf16MaxLen)
 Converts a UTF-8 string to UTF-16.


Member Function Documentation

size_t Decode const char *  utf8,
size_t  utf8Len,
uint16_t *  utf16,
size_t  utf16MaxLen
[static]
 

Converts a UTF-8 string to UTF-16.

Parameters:
utf8 the UTF-8 text
utf8Len the number of bytes in the UTF-8 text
utf16 the output buffer for the UTF-16 text
utf16MaxLen the maximum number of (16-bit) characters to write to the output buffer
Returns:
the number of (16-bit) characters written to the output buffer (that is, the length of the UTF-16 string)

size_t DecodeLen const char *  utf8,
size_t  utf8Len
[static]
 

Gets the length of the UTF-16 string that would result from decoding the UTF-8 string.

You may use this function to determine the required length of the array you need for the UTF-16 string. The return value is the length of the UTF-16 string in (16-bit) characters.

Parameters:
utf8 the UTF-8 text
utf8Len the number of bytes in the UTF-8 text
Returns:
the length in (16-bit) characters of the UTF-16 text

size_t Encode const uint16_t *  utf16,
size_t  utf16Len,
char *  utf8,
size_t  utf8MaxLen
[static]
 

Converts a UTF-16 string to UTF-8.

Parameters:
utf16 the UTF-16 text
utf16Len the number of (16-bit) characters in the UTF-16 text
utf8 the output buffer for the UTF-8 text
utf8MaxLen the maximum number of bytes to write to the output buffer
Returns:
the number of bytes written to the output buffer (that is, the length of the UTF-8 string in bytes)

size_t EncodeLen const uint16_t *  utf16,
size_t  utf16Len
[static]
 

Gets the length of the UTF-8 string that would result from encoding the UTF-16 string.

You may use this function to determine the required length of the array you need for the UTF-8 string. The return value is the length of the UTF-8 string in bytes.

Parameters:
utf16 the UTF-16 text
utf16Len the number of (16-bit) characters in the UTF-16 text
Returns:
the length in bytes of the UTF-8 text

Copyright © 2001-2005 Hunny Software, Inc. All rights reserved.