Generic Text Encoding Scheme. More...
#include <rtextencoding.h>
Data Structures | |
struct | UnicodeCharacter |
Unicode Character Structure. | |
Public Member Functions | |
RTextEncoding (const RCString &name) | |
virtual void | Init (void) const |
const RCString & | GetName (void) const |
int | Compare (const RTextEncoding &enc) const |
int | Compare (const RCString &name) const |
virtual RString | ToUnicode (const char *text, size_t len) const |
virtual UnicodeCharacter | NextUnicode (const char *text, size_t &len, bool invalid=false) const |
virtual RCString | FromUnicode (const RChar *text, size_t len, bool invalid) const |
virtual RCString | FromUnicode (const RString &text, bool invlaid) const |
virtual | ~RTextEncoding (void) |
Static Public Member Functions | |
static RTextEncoding * | GetTextEncoding (const RCString &name) |
static RTextEncoding * | GetUTF8Encoding (void) |
Private Attributes | |
RCString | Name |
void * | ToUTF16 |
void * | FromUTF16 |
Detailed Description
Generic Text Encoding Scheme.
This class provides a representation for a generic text encoding scheme other than Unicode UTF-16 used internally by the R library.
Actually, there is only a single class implementing the functions proposed in <iconv.h>. In practice, it uses the UTF-16 little-endian encoding scheme for internal transformation from and to RString.
Constructor & Destructor Documentation
RTextEncoding | ( | const RCString & | name | ) |
Construct a particular encoding.
- Parameters
-
name Name of the encoding.
|
virtual |
Destruct the encoding.
Member Function Documentation
|
virtual |
Initialize the text encoding.
const RCString& GetName | ( | void | ) | const |
Return the name of the file.
- Returns
- a string containing the name.
int Compare | ( | const RTextEncoding & | enc | ) | const |
Lexically compares two strings and returns an integer less than, equal to, or greater than zero if this is less than, equal to, or greater than enc.
- Parameters
-
enc Encoding to compare with.
- See also
- R::RContainer.
int Compare | ( | const RCString & | name | ) | const |
Lexically compares two strings and returns an integer less than, equal to, or greater than zero if this is less than, equal to, or greater than name.
- Parameters
-
name Name of encoding.
- See also
- R::RContainer.
|
virtual |
Transform a string of the given encoding to a string in Unicode.
- Parameters
-
text Text in the given encoding. len Number of character to convert.
- Returns
- RString.
|
virtual |
Read the next Unicode character contained in a string of the given encoding.
- Parameters
-
text Text in the given encoding. len Number of character to analyzed. After the call, this parameters contains the number of bytes read. invalid If true, invalid characters are allowed. If false, an exception is generated.
Transform a string in Unicode to a string of the given encoding.
- Parameters
-
text Unicode string. len Length of the string. invalid If true, invalid characters are allowed. If false, an exception is generated.
- Returns
- RCString.
Transform a string in Unicode to a string of the given encoding.
- Parameters
-
text Unicode string. invalid If true, invalid characters are allowed. If false, an exception is generated.
- Returns
- RCString.
|
static |
This method returns a text encoding scheme based on a name. The method constructs a text encoding for UTF-16 the first time it is used.
The encoding schemes are added when they are requested.
- Parameters
-
name Name of encoding.
- Returns
- Pointer to a RTextEncoding.
|
static |
This method returns a text encoding UTF8. The method constructs a text encoding for UTF-16 the first time it is used.
The encoding schemes are added when they are requested.
- Returns
- Pointer to a RTextEncoding.
Field Documentation
|
private |
The name of the encoding (always in upper case).
|
private |
Descriptor used to make the conversion to Unicode UTF-16.
|
private |
Descriptor used to make the conversion from Unicode UTF-16.