Jameo Core Library
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
jm::Charset Class Reference

The class Charset is a factory class to make a string out of arbitrarily coded C-strings and vice versa. More...

Inheritance diagram for jm::Charset:
jm::Object

Public Member Functions

 Charset (CharsetDecoder *decoder)
 Special constructor for the static initialisation of the default decoder. This is always the UTF-8 encoding.
 
 Charset (const char *name, CharsetDecoder *decoder)
 Constructor for the static initialisation (therefore not a string).
 
 Charset (const String &name, const String *alternatives, uint8 altCount, CharsetDecoder *decoder)
 Constructor.
 
 ~Charset () override
 Destructor.
 
const Stringname () const
 This method returns the name of the character set.
 
bool hasName (const String &name) const
 This method tests whether the character set is addressed under the desired name.
 
CharArray decode (const char *cString)
 This method decodes the C-string and generates a chararray that has been converted through the encoding.
 
ByteArray encode (const CharArray &string)
 This Method generates the corresponding C-string from a string using this character set.
 
- Public Member Functions inherited from jm::Object
 Object () noexcept
 Constructor.
 
virtual ~Object () noexcept
 Destructor.
 
void release () noexcept
 Decreases the reference counter and releases the object immediately when the reference counter becomes 0.
 
Objectretain () noexcept
 Increases the reference counter of this object by 1.
 
Objectautorelease () noexcept
 Same function as release(), but releases the object with a delay if the reference counter is 0. AutoreleasePool::drain() must be called in the to release the object.
 
int32 referenceCount () const noexcept
 Returns the value of the reference counter.
 
virtual bool equals (const Object *other) const
 Comparison of objects.
 
virtual String displayName () const
 Returns the display name of the object intended to present to a user.
 
virtual void printDiffInfo (DiffOperation operation, Object *other) const
 Output method for outputting the diff results for the diff algorithm.
 
void setHighBit (bool status) noexcept
 
bool highBit () const noexcept
 

Static Public Member Functions

static CharsetforName (const String &name)
 This method returns the desired charset by name.
 
static CharsetgetDefault ()
 This method returns the default character set (UTF-8).
 
static String guess (const char *stream, size_t length)
 This method guesses the character encoding from the given array and returns the guessed name. If no character set is recognised, depending on the operating system, the default character set is returned. Corresponding to the operating system, those are the following:
 

Friends

void quitCharsets ()
 Deletes the charset objects.
 

Detailed Description

The class Charset is a factory class to make a string out of arbitrarily coded C-strings and vice versa.

Constructor & Destructor Documentation

◆ Charset() [1/3]

jm::Charset::Charset ( CharsetDecoder decoder)
explicit

Special constructor for the static initialisation of the default decoder. This is always the UTF-8 encoding.

◆ Charset() [2/3]

jm::Charset::Charset ( const char *  name,
CharsetDecoder decoder 
)

Constructor for the static initialisation (therefore not a string).

Parameters
nameName of the character set
decoderThe decoder for this character set

◆ Charset() [3/3]

jm::Charset::Charset ( const String name,
const String alternatives,
uint8  altCount,
CharsetDecoder decoder 
)

Constructor.

Parameters
nameName of the character set
alternativesAlternative names for the character set
altCountNumber of alternative names for this character set
decoderThe decoder for this character set

◆ ~Charset()

jm::Charset::~Charset ( )
override

Destructor.

Member Function Documentation

◆ decode()

CharArray jm::Charset::decode ( const char *  cString)

This method decodes the C-string and generates a chararray that has been converted through the encoding.

Parameters
cStringThe C-string that is to be converted.

◆ encode()

ByteArray jm::Charset::encode ( const CharArray string)

This Method generates the corresponding C-string from a string using this character set.

Parameters
stringThe C-string that is to be converted.

◆ forName()

static Charset * jm::Charset::forName ( const String name)
static

This method returns the desired charset by name.

Parameters
nameThe name of the charset.
Returns
The charset, or NULL, if the charset for name was not found.

◆ getDefault()

static Charset * jm::Charset::getDefault ( )
static

This method returns the default character set (UTF-8).

◆ guess()

static String jm::Charset::guess ( const char *  stream,
size_t  length 
)
static

This method guesses the character encoding from the given array and returns the guessed name. If no character set is recognised, depending on the operating system, the default character set is returned. Corresponding to the operating system, those are the following:

  • Windows: Windows-1252
  • Mac: MacRoman
  • Linux: UTF-8 However, even if one of the values above is returned it does not automatically mean that no character set was recognised.

◆ hasName()

bool jm::Charset::hasName ( const String name) const

This method tests whether the character set is addressed under the desired name.

Parameters
nameThe name that is to be checked using this method.
Returns
Returns true if either the name of the character set or one of the alternative names matches name. Otherwise, return value is false.

◆ name()

const String & jm::Charset::name ( ) const

This method returns the name of the character set.

Friends And Related Symbol Documentation

◆ quitCharsets

void quitCharsets ( )
friend

Deletes the charset objects.

Note
Called by System::quit. Therefore no export or direct call by developer necessary.