IConverter Class Reference
#include <cxxtools/iconverter.h>
List of all members.
|
Public Member Functions |
|
| IConverter (const std::string &tocode_, const std::string &fromcode_) |
|
void | setToCode (const std::string &tocode_) |
|
void | setFromCode (const std::string &fromcode_) |
|
const std::string & | getToCode () const |
|
const std::string & | getFromCode () const |
|
template<typename objT> |
| std::string | convert (objT s) const |
|
std::string | convert (const char *data, unsigned size) const |
|
template<typename iteratorT> |
| std::string | convertRange (iteratorT begin, iteratorT end) const |
|
template<typename objT> |
| std::string | operator() (objT s) const |
|
std::string | operator() (const char *data, unsigned size) const |
Detailed Description
IConverter is a simple wrapper around
cxxtools::iconvstream.
Often the result of a character-conversion is needed as a std::string. This can be achived to let iconvstream to a ostringstream and get the string from the ostringstream. IConverter simplify this.
example: convert a UTF8-encoded string to ISO8859-1:
cxxtools::IConverter conv("ISO8859-1", "UTF8");
std::string utf8string = getUtf8String();
std::string iso8895_1 = conv.convert(utf8string);
std::string iso8895_1 = conv(utf8string);