|
OpenTop 1.3 | |||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||
| SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD | |||||
#include "ot/cvt/CodeConverter.h"

OpenTop comes supplied with CodeConverters for many common encodings such as UTF-8, UTF-16, Latin1 and many others.
| Constructor/Destructor Summary | |
CodeConverter()Creates a CodeConverter with default values. | |
| Method Summary | |
virtual bool |
alwaysNoConversion() constTests if this CodeConverter is using the same encoding as the OpenTop internal encoding. |
virtual Result |
decode(const Byte* from, const Byte* from_end, const Byte*& from_next, CharType* to, CharType* to_limit, CharType*& to_next)Decodes an array of bytes into an array of CharType characters that represent Unicode characters in the internal OpenTop encoding. |
virtual Result |
encode(const CharType* from, const CharType* from_end, const CharType*& from_next, Byte* to, Byte* to_limit, Byte*& to_next)Encodes an array of CharType characters, representing Unicode characters in the internal OpenTop encoding, into an array of bytes. |
virtual size_t |
getDecodedLength(const Byte* from, const Byte* from_end) constReturns the number of Unicode characters that would be created by decoding the array of bytes starting at from. |
virtual String |
getEncodingName() constReturns the canonical name for the encoding handled by this CodeConverter. |
CharAction |
getInvalidCharAction() constReturns the policy for dealing with invalid byte sequences. |
UCS4Char |
getInvalidCharReplacement() constReturns the Unicode character that will be used when this CodeConverter detects an invalid byte sequence. |
virtual size_t |
getMaxEncodedLength() constReturns the maximum number of bytes used to encode a single Unicode character up to U+10FFFF. |
CharAction |
getUnmappableCharAction() constReturns the policy for dealing with Unicode characters that cannot be mapped into the target encoding. |
UCS4Char |
getUnmappableCharReplacement() constReturns the Unicode character that will be used when this CodeConverter detects an unmappable Unicode character. |
protected void |
handleInvalidByteSequence(const Byte* from, size_t len) constHelper function that simply throws a MalformedInputException. |
protected virtual Result |
handleUnmappableCharacter(UCS4Char ch, Byte* to, Byte* to_limit, Byte*& to_next)Helper function called by derived classes' encode() method when it encounters an unmappable Unicode character. |
protected void |
internalEncodingError(const CharType* from, size_t len) constHelper function called by derived classes when they encounter a badly encoded internal CharType array. |
void |
setInvalidCharAction(CharAction eAction)Sets the policy for dealing with badly encoded byte sequences. |
void |
setInvalidCharReplacement(UCS4Char ch)Sets the replacement Unicode character used when the CodeConverter detects an invalid byte sequence. |
void |
setUnmappableCharAction(CharAction eAction)Sets the policy for dealing with Unicode characters that cannot be mapped into the target encoding. |
void |
setUnmappableCharReplacement(UCS4Char ch)Sets the replacement Unicode character used when the CodeConverter detects a Unicode character than cannot be encoded into the target encoding. |
protected void |
throwUnsupported(unsigned long illegalChar) const |
| Methods inherited from class ot::CodeConverterBase |
IsLegalUTF16, IsLegalUTF8, UTF8Decode, UTF8Encode |
| Methods inherited from class ot::ManagedObject |
addRef, getRefCount, onFinalRelease, operator=, release |
| Enumerations |
enum CharAction { |
abort, |
|
|
replace} |
|
| Constructor/Destructor Detail |
CodeConverter()
| Method Detail |
virtual bool alwaysNoConversion() const
virtual Result decode(const Byte* from,
const Byte* from_end,
const Byte*& from_next,
CharType* to,
CharType* to_limit,
CharType*& to_next)
from - from_end - from_next - to - to_limit - to_next - MalformedInputException - virtual Result encode(const CharType* from,
const CharType* from_end,
const CharType*& from_next,
Byte* to,
Byte* to_limit,
Byte*& to_next)
from - from_end - from_next - to - to_limit - to_next - UnmappableCharacterException - virtual size_t getDecodedLength(const Byte* from,
const Byte* from_end) const
from - from_end - virtual String getEncodingName() const
CharAction getInvalidCharAction() const
UCS4Char getInvalidCharReplacement() const
virtual size_t getMaxEncodedLength() const
CharAction getUnmappableCharAction() const
UCS4Char getUnmappableCharReplacement() const
protected void handleInvalidByteSequence(const Byte* from,
size_t len) const
MalformedInputException - protected virtual Result handleUnmappableCharacter(UCS4Char ch,
Byte* to,
Byte* to_limit,
Byte*& to_next)
ch - to - to_limit - to_next - protected void internalEncodingError(const CharType* from,
size_t len) const
from - void setInvalidCharAction(CharAction eAction)
When the action is set to CodeConverter::abort, a MalformedInputException is thrown by decode() when an invalid byte sequence is decoded. When the action is set to CodeConverter::replace, the invalid byte sequence is decoded as the replacement character returned from getInvalidCharReplacement().
eAction - void setInvalidCharReplacement(UCS4Char ch)
void setUnmappableCharAction(CharAction eAction)
When the action is set to CodeConverter::abort, an UnmappableCharacterException is thrown by encode() when an unmappable Unicode character is encoded. When the action is set to CodeConverter::replace, the unmappable character is replaced by the character returned from getUnmappableCharReplacement().
eAction - void setUnmappableCharReplacement(UCS4Char ch)
protected void throwUnsupported(unsigned long illegalChar) const
|
OpenTop 1.3 | |||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||
| SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD | |||||