te::core::CharEncoding Class Reference

A class for handling character enconding/decoding. More...

#include <CharEncoding.h>

Static Public Member Functions

static std::string convert (const std::string &src, EncodingType from, EncodingType to)
 Convert a string from one character encoding to another one. More...
 
static std::string fromUTF8 (const std::string &src)
 Convert a string in UTF-8 to the current locale encoding. More...
 
static std::string fromUTF8 (const std::string &src, EncodingType to)
 Convert a string in UTF-8 to another character encoding. More...
 
static std::vector< std::string > getEncodingList ()
 Retrive a vector of string with all available encoding types name. More...
 
static std::string getEncodingName (EncodingType et)
 Retrive a string from a given character encoding type enum. More...
 
static te::core::EncodingType getEncodingType (const std::string &name)
 Retrive an EncodingType from a given character encoding name. More...
 
static std::string toASCII (const std::string &src)
 Decomposes a UTF-8 encoded string and extracts its ASCII characters. More...
 
static std::string toUTF8 (const std::string &src)
 Convert a string from a current locale encoding to UTF-8. More...
 
static std::string toUTF8 (const std::string &src, EncodingType from)
 Convert a string from a given character encoding to UTF-8. More...
 

Private Member Functions

 CharEncoding ()
 
 CharEncoding (CharEncoding const &)
 
CharEncodingoperator= (CharEncoding const &)
 
 ~CharEncoding ()
 

Detailed Description

A class for handling character enconding/decoding.

Definition at line 67 of file CharEncoding.h.

Constructor & Destructor Documentation

te::core::CharEncoding::CharEncoding ( )
private
te::core::CharEncoding::~CharEncoding ( )
private
te::core::CharEncoding::CharEncoding ( CharEncoding const &  )
private

Member Function Documentation

static std::string te::core::CharEncoding::convert ( const std::string &  src,
EncodingType  from,
EncodingType  to 
)
static

Convert a string from one character encoding to another one.

Parameters
srcString encoded according to "from" encoding type.
fromCurrent string encoding.
toNew encoding for the string.
Returns
String in a new encoding.
static std::string te::core::CharEncoding::fromUTF8 ( const std::string &  src)
static

Convert a string in UTF-8 to the current locale encoding.

Parameters
srcUTF-8 string.
Exceptions
te::Exceptionif the system locale cannot be retrieved.
Returns
String encoded according to new character encoding.

Referenced by te::rp::Matrix< TemplateElementType >::createNewDiskFile().

static std::string te::core::CharEncoding::fromUTF8 ( const std::string &  src,
EncodingType  to 
)
static

Convert a string in UTF-8 to another character encoding.

Parameters
srcUTF-8 string.
toThe target character encoding.
Returns
String encoded according to new character encoding.
static std::vector<std::string> te::core::CharEncoding::getEncodingList ( )
static

Retrive a vector of string with all available encoding types name.

Returns
A vector of encoding type as string.
static std::string te::core::CharEncoding::getEncodingName ( EncodingType  et)
static

Retrive a string from a given character encoding type enum.

Parameters
etEncoding Type to be retrieved as string.
Returns
Encoding Type as string.
static te::core::EncodingType te::core::CharEncoding::getEncodingType ( const std::string &  name)
static

Retrive an EncodingType from a given character encoding name.

Parameters
nameEncoding name to be retrieved as enum.
Returns
Encoding as enum.
CharEncoding& te::core::CharEncoding::operator= ( CharEncoding const &  )
private
static std::string te::core::CharEncoding::toASCII ( const std::string &  src)
static

Decomposes a UTF-8 encoded string and extracts its ASCII characters.

Note
Non-ascii characters will be skipped.
Parameters
srcUTF-8 encoded string.
Exceptions
te::Exceptionif the given string cannot be decomposed.
Returns
ASCII String.
static std::string te::core::CharEncoding::toUTF8 ( const std::string &  src)
static

Convert a string from a current locale encoding to UTF-8.

Parameters
srcString to be encoded in UTF-8.
Exceptions
te::Exceptionif the system locale cannot be retrieved.
Returns
String encoded in UTF-8.
static std::string te::core::CharEncoding::toUTF8 ( const std::string &  src,
EncodingType  from 
)
static

Convert a string from a given character encoding to UTF-8.

Parameters
srcString to be encoded in UTF-8.
Returns
String encoded in UTF-8.

The documentation for this class was generated from the following file: