Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CP_UTF8TextEncoder Class Reference
[TextHandling]

CP_TextEncoder class to provide text encoded in UTF-8 encoding. More...

Inheritance diagram for CP_UTF8TextEncoder:

CP_TextEncoder CP_NoCopy List of all members.

Public Member Functions

Constructor / Destructor
 CP_UTF8TextEncoder (bool inUseCompositeChars=false)
 Constructor.
virtual ~CP_UTF8TextEncoder ()
 Destructor.
Cloning
virtual CP_TextEncoderClone () const
Converters
virtual UInt32 ToUTF16 (const char *inSrcChars, UInt32 inSrcLength, CPUniChar *inDestChars, UInt32 inDestLength) const
virtual UInt32 FromUTF16 (const CPUniChar *inSrcChars, UInt32 inSrcLength, char *inDestChars, UInt32 inDestLength) const
Getters
virtual UInt32 GetDestLength (const char *inSrcChars, UInt32 inSrcLength) const
virtual UInt32 GetEncodingType () const

Static Public Member Functions

static const CP_UTF8TextEncoderSharedTextEncoder ()
 Accessor for shared text encoder object.
static CP_MutexSharedTextEncoderMutex ()
 Get Mutex for synchronizing access to shared text encoder object.

Protected Attributes

bool fUseSystemEncoder
TECObjectRef fTo16TEC
TECObjectRef fFrom16TEC
bool fHasMacCodePage
UInt32 fTextFormat
bool fUseCompositeCharacters
UInt32 fConvertToUTF16Flags
UInt32 fConvertFromUTF16Flags
const CPUniCharfEncoding
TextToUnicodeInfo fTextToUnicodeInfo
UnicodeToTextInfo fUnicodeToTextInfo

Private Member Functions

Testers
bool IsValidUTF8ForSystem (const char *inSrcChars, UInt32 inSrcLength) const
bool IsValidUTF8 (const char *inSrcChars, UInt32 inSrcLength) const
bool IsValidUTF16ForSystem (const CPUniChar *inSrcChars, UInt32 inSrcLength) const
bool IsValidUTF16 (const CPUniChar *inSrcChars, UInt32 inSrcLength) const

Detailed Description


Constructor & Destructor Documentation

CP_UTF8TextEncoder::CP_UTF8TextEncoder bool  inUseCompositeCharacters = false  ) 
 

Constructor.

Parameters:
inuseCompositeChars Flag used to indicate if composite characters are to be used in the conversion.
Exceptions:
none 

CP_UTF8TextEncoder::~CP_UTF8TextEncoder  )  [virtual]
 

Destructor.


Member Function Documentation

const CP_UTF8TextEncoder * CP_UTF8TextEncoder::SharedTextEncoder  )  [static]
 

Returns the shared instance of a CP_UTF8TextEncoder.

Note:
If you're running multi-threaded, you'll have to lock access to the shared encoder object while using it. Use the mutex provided by CP_UTF8TextEncoder::SharedTextEncoderMutex, or lock access using the convenience macro CP_UTF8TextEncoder.
Exceptions:
none 
Returns:
const CP_UTF8TextEncoder* The shared text encoder instance.
See also:
CP_LockSharedTextEncoder, CP_UTF8TextEncoder::SharedTextEncoderMutex

CP_Mutex & CP_UTF8TextEncoder::SharedTextEncoderMutex  )  [static]
 

Exceptions:
none 
Returns:
CP_Mutex& Mutex to use for synchronizing usage of shared text encoder object.

CP_TextEncoder * CP_UTF8TextEncoder::Clone  )  const [virtual]
 

Returns a new text encoder object of the same type as this object.

Exceptions:
none 
Returns:
CP_TextEncoder * const The new text encoder object.

Implements CP_TextEncoder.

UInt32 CP_UTF8TextEncoder::ToUTF16 const char *  inSrcChars,
UInt32  inSrcLength,
CPUniChar inDestChars,
UInt32  inDestLength
const [virtual]
 

Converts the passed in string to UTF16 encoding.

Parameters:
inSrcChars The string to be converted.
inSrcLength Number of characters in source string to use.
inDestChars CPUniChar buffer to receive the result.
inDestLength Length of the buffer to place the results in. This is the maximum number of characters that will be copied. If the buffer is to SInt16 for the conversion, some characters will be lost.
Exceptions:
none 
Returns:
UInt32 The length of the converted string.

Reimplemented from CP_TextEncoder.

UInt32 CP_UTF8TextEncoder::FromUTF16 const CPUniChar inSrcChars,
UInt32  inSrcLength,
char *  inDestChars,
UInt32  inDestLength
const [virtual]
 

Converts the passed in string from UTF16 encoding to the encoders type.

Parameters:
inSrcChars The UTF16 string to be converted.
inSrcLength Number of characters in source string to use.
inDestChars char buffer to receive the result.
inDestLength Length of the buffer to place the results in. This is the maximum number of characters that will be copied. If the buffer is to SInt16 for the conversion, some characters will be lost.
Exceptions:
none 
Returns:
UInt32 The length of the converted string.

Reimplemented from CP_TextEncoder.

UInt32 CP_UTF8TextEncoder::GetDestLength const char *  inSrcChars,
UInt32  inSrcLength
const [virtual]
 

Returns the approximate length that the converted passed in string will occupy. You can use this before converting the text to get an approximate size of the converted text to know how much memory to allocate for the buffer to hold the converted text. The returned length is only an approximation, as no actual conversion takes place.

Parameters:
inSrcChars Character string containing the characters to be converted.
inSrcLength The number of characters from the source buffer to convert.
Exceptions:
none 
Returns:
UInt32 The approximate length of the conversion.

Reimplemented from CP_TextEncoder.

virtual UInt32 CP_UTF8TextEncoder::GetEncodingType  )  const [virtual]
 

Reimplemented from CP_TextEncoder.

bool CP_UTF8TextEncoder::IsValidUTF8ForSystem const char *  inSrcChars,
UInt32  inSrcLength
const [private]
 

Used to determine if the passed in char * text is valid for the encoding converted on the installed OS.

Parameters:
inSrcChars char * string containing the characters to be converted.
inSrcLength The number of characters from the source buffer to convert.
Exceptions:
none 
Returns:
bool The text is valid UTF8 for the system to convert.

bool CP_UTF8TextEncoder::IsValidUTF8 const char *  inSrcChars,
UInt32  inSrcLength
const [private]
 

Used to determine if the passed in char * text is valid UTF8 text.

Parameters:
inSrcChars char * string containing the characters to be converted.
inSrcLength The number of characters from the source buffer to convert.
Exceptions:
none 
Returns:
bool The text is valid UTF8.

bool CP_UTF8TextEncoder::IsValidUTF16ForSystem const CPUniChar inSrcChars,
UInt32  inSrcLength
const [private]
 

Used to determine if the passed in CPUniChar * text is valid for the encoding converted on the installed OS.

Parameters:
inSrcChars CPUniChar * string containing the characters to be converted.
inSrcLength The number of characters from the source buffer to convert.
Exceptions:
none 
Returns:
bool The text is valid UTF16 for the system to convert.

bool CP_UTF8TextEncoder::IsValidUTF16 const CPUniChar inSrcChars,
UInt32  inSrcLength
const [private]
 

Used to determine if the passed in CPUniChar * text is valid UTF16 text.

Parameters:
inSrcChars CPUniChar * string containing the characters to be converted.
inSrcLength The number of characters from the source buffer to convert.
Exceptions:
none 
Returns:
bool The text is valid UTF16.

void CP_TextEncoder::SetConvertToUTF16Flags UInt32  inFlags = 0  )  [inherited]
 

Sets up the flags and various data members based on the passed in flags which are used to determine features and how errors are handled in the conversion.

Parameters:
inFlags Flags used to determine how the conversion takes place, and error handling.
Exceptions:
none 
Returns:
void

void CP_TextEncoder::SetConvertFromUTF16Flags UInt32  inFlags = 0  )  [inherited]
 

Sets up the flags and various data members based on the passed in flags which are used to determine features and how errors are handled in the conversion.

Parameters:
inFlags Flags used to determine how the conversion takes place, and error handling.
Exceptions:
none 
Returns:
void

UInt32 CP_TextEncoder::GetDestLength const CPUniChar inSrcChars,
UInt32  inSrcLength
const [virtual, inherited]
 

Returns the approximate length that the converted passed in string will occupy. You can use this before converting the text to get an approximate size of the converted text to know how much memory to allocate for the buffer to hold the converted text. The returned length is only an approximation, as no actual conversion takes place.

Parameters:
inSrcChars CPUniChar * string containing the characters to be converted.
inSrcLength The number of characters from the source buffer to convert.
Exceptions:
none 
Returns:
UInt32 The approximate length of the conversion.

Reimplemented in CP_MacRomanTextEncoder.

const CPUniChar* CP_TextEncoder::GetEncoding  )  const [inherited]
 

Return the name of this encoder as a CPUniChar * string.

bool CP_TextEncoder::HasTextEncodingConverter  )  const [protected, inherited]
 

UnicodeToTexUnicode info structure used on the Mac.

SInt32 CP_TextEncoder::GetTECVersion  )  const [protected, inherited]
 

MacOS - Returns the version of the TextEncoding Converter installed on the MacOS.

Exceptions:
none 
Returns:
SInt32 The Text Encoding Converter installed.


Member Data Documentation

bool CP_UTF8TextEncoder::fUseSystemEncoder [protected]
 

TECObjectRef CP_UTF8TextEncoder::fTo16TEC [mutable, protected]
 

Flag to indicate if the encoding is done by the system.

TECObjectRef CP_UTF8TextEncoder::fFrom16TEC [mutable, protected]
 

Mac TextEncoding ref to go to UTF16 encoding.

bool CP_UTF8TextEncoder::fHasMacCodePage [protected]
 

Mac TextEncoding ref to go from UTF16 encoding.

UInt32 CP_TextEncoder::fTextFormat [protected, inherited]
 

bool CP_TextEncoder::fUseCompositeCharacters [protected, inherited]
 

Format of the text.

UInt32 CP_TextEncoder::fConvertToUTF16Flags [protected, inherited]
 

Flag to indicate if we are using composite characters.

UInt32 CP_TextEncoder::fConvertFromUTF16Flags [protected, inherited]
 

Flag used in converting to UTF16.

const CPUniChar* CP_TextEncoder::fEncoding [protected, inherited]
 

Flag used in converting from UTF16.

TextToUnicodeInfo CP_TextEncoder::fTextToUnicodeInfo [mutable, protected, inherited]
 

The encoding being used, expressed as a CPUniChar *string.

UnicodeToTextInfo CP_TextEncoder::fUnicodeToTextInfo [mutable, protected, inherited]
 

TextToUnicode info structure used on the Mac.


The documentation for this class was generated from the following files:
Generated on Sat Sep 17 20:02:24 2005 for CPLAT by  doxygen 1.4.0