gtkutil::IConv Class Reference

#include <IConv.h>

Public Member Functions

 IConv (const std::string &to_codeset, const std::string &from_codeset)
 ~IConv ()
size_t iconv (char **inbuf, gsize *inbytes_left, char **outbuf, gsize *outbytes_left)
void reset ()
std::string convert (const std::string &str)
GIConv gobj ()

Static Public Member Functions

static std::string localeToUTF8 (const std::string &input)
static std::string localeFromUTF8 (const std::string &input)
static std::string filenameToUTF8 (const std::string &input)

Private Attributes

GIConv gobject_

Detailed Description

greebo: This is a wrapper class around the iconv functions. Many codeparts have been taken from the GLib::IConv class in the glibmm 2.14.2 library.

Definition at line 19 of file IConv.h.


Constructor & Destructor Documentation

gtkutil::IConv::IConv ( const std::string to_codeset,
const std::string from_codeset 
) [inline]

Open new conversion descriptor.

Parameters:
to_codeset Destination codeset.
from_codeset Source codeset.

Definition at line 29 of file IConv.h.

References gobject_.

gtkutil::IConv::~IConv (  )  [inline]

Close conversion descriptor.

Definition at line 47 of file IConv.h.

References gobject_.


Member Function Documentation

std::string gtkutil::IConv::convert ( const std::string str  )  [inline]

Convert from one encoding to another.

Parameters:
str The string to convert.
Returns:
The converted string.
Exceptions:
Glib::ConvertError 

Definition at line 90 of file IConv.h.

References gobject_, and string.

static std::string gtkutil::IConv::filenameToUTF8 ( const std::string input  )  [inline, static]

greebo: Converts the given filename to UTF-8. Returns an empty string if the conversion fails.

Definition at line 159 of file IConv.h.

References string.

GIConv gtkutil::IConv::gobj (  )  [inline]

Definition at line 108 of file IConv.h.

References gobject_.

size_t gtkutil::IConv::iconv ( char **  inbuf,
gsize *  inbytes_left,
char **  outbuf,
gsize *  outbytes_left 
) [inline]

Same as the standard UNIX routine iconv(), but may be implemented via libiconv on UNIX flavors that lack a native implementation. glibmm provides Glib::convert() and Glib::locale_to_utf8() which are likely more convenient than the raw iconv wrappers.

Parameters:
inbuf Bytes to convert.
inbytes_left In/out parameter, bytes remaining to convert in inbuf.
outbuf Converted output bytes.
outbytes_left In/out parameter, bytes available to fill in outbuf.
Returns:
Count of non-reversible conversions, or static_cast<size_t>(-1) on error.

Definition at line 62 of file IConv.h.

References gobject_.

static std::string gtkutil::IConv::localeFromUTF8 ( const std::string input  )  [inline, static]

greebo: Converts the given string from UTF-8 to the current locale. Returns an empty string if the conversion fails.

Definition at line 138 of file IConv.h.

References string.

static std::string gtkutil::IConv::localeToUTF8 ( const std::string input  )  [inline, static]

greebo: Converts the given string to UTF-8 encoding. Returns an empty string if the conversion fails.

Definition at line 117 of file IConv.h.

References string.

void gtkutil::IConv::reset (  )  [inline]

Reset conversion descriptor to initial state. Same as iconv(0, 0, 0, 0), but implemented slightly differently in order to work on Sun Solaris <= 7. It's also more obvious so you're encouraged to use it.

Definition at line 72 of file IConv.h.

References gobject_.


Field Documentation

GIConv gtkutil::IConv::gobject_ [private]

Definition at line 22 of file IConv.h.

Referenced by convert(), gobj(), iconv(), IConv(), reset(), and ~IConv().


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

Generated by  doxygen 1.6.2