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

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.

Definition at line 106 of file CharEncoding.cpp.

References EncodingString.

Referenced by BOOST_AUTO_TEST_CASE().

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.

Definition at line 77 of file CharEncoding.cpp.

References TE_LOG_ERROR, and TE_TR.

Referenced by BOOST_AUTO_TEST_CASE(), terralib4::Convert2Latin1(), te::core::FileSystem::copyFile(), te::core::FileSystem::createDirectories(), te::core::FileSystem::createDirectory(), te::mem::ExpansibleBandBlocksManager::createNewDiskFile(), te::rp::Matrix< TemplateElementType >::createNewDiskFile(), te::ws::core::CurlWrapper::downloadFile(), te::qt::plugins::terramobile::GeopackagePublisher::downloadGeopackageFile(), te::core::FileSystem::exists(), te::sa::SpatialWeightsExchanger::exportToGAL(), te::sa::SpatialWeightsExchanger::exportToGWT(), te::core::FileSystem::fileSize(), te::qt::widgets::HidroItem::getCtlParameters(), te::qt::widgets::Eta5kmItem::getCtlParameters(), te::qt::widgets::ImageItem::getCtlParameters(), te::core::FileSystem::isDirectory(), te::core::FileSystem::isEmpty(), te::core::FileSystem::isRegularFile(), te::core::FileSystem::listDirectory(), te::qt::widgets::HidroItem::loadCurrentImage(), te::qt::widgets::Eta5kmItem::loadCurrentImage(), TsGEOSWriterReader::loadGeometry(), TsGeometry::loadGeometry(), TsWKBReader::loadWKT(), TsGEOSWriterReader::loadWKT(), main(), te::qt::widgets::TimeSliderWidget::onAnimationDragEnterEvent(), te::da::CharEncodingConverter::operator()(), te::xerces::Reader::read(), te::v8::common::ReadFile(), te::core::FileSystem::remove(), te::core::FileSystem::rename(), te::core::FileSystem::systemCompletePath(), and te::xerces::Writer::writeToFile().

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.

Definition at line 100 of file CharEncoding.cpp.

References EncodingString.

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.

Definition at line 159 of file CharEncoding.cpp.

References EncodingString.

Referenced by BOOST_FIXTURE_TEST_SUITE(), te::qt::widgets::CharEncodingMenuWidget::CharEncodingMenuWidget(), te::qt::widgets::DataSetOptionsWizardPage::fillCharEncodingTypes(), and te::qt::widgets::CharEncodingMenuWidget::onEncodingClicked().

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.

Definition at line 146 of file CharEncoding.cpp.

References EncodingString, and TE_TR.

Referenced by te::qt::widgets::DataSetOptionsWizardPage::applyChanges(), BOOST_FIXTURE_TEST_SUITE(), DataSetLayerReader(), te::ws::ogc::wms::serialize::LayerReader(), te::qt::widgets::CharEncodingMenuWidget::onEncodingClicked(), and QueryLayerReader().

CharEncoding& te::core::CharEncoding::operator= ( CharEncoding const &  )
private
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.

Definition at line 113 of file CharEncoding.cpp.

References TE_LOG_ERROR, and TE_TR.

Referenced by BOOST_AUTO_TEST_CASE().

std::string te::core::CharEncoding::toUTF8 ( const std::string &  src)
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.

Definition at line 51 of file CharEncoding.cpp.

References EncodingString.


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