aboutsummaryrefslogtreecommitdiffhomepage
path: root/gtk/Converter.h
diff options
context:
space:
mode:
authornyamatongwe <unknown>2004-02-03 11:02:46 +0000
committernyamatongwe <unknown>2004-02-03 11:02:46 +0000
commit98b2a27ccd8e9ecf70370a8e1b4e8e100bde29ba (patch)
tree42cabc339dc220ee0ad77ba2e43bb93f2b079730 /gtk/Converter.h
parent4929c35cee05de21bb34c9c25160969c73916b61 (diff)
downloadscintilla-mirror-98b2a27ccd8e9ecf70370a8e1b4e8e100bde29ba.tar.gz
Use g_iconv on GTK+ 2.
Diffstat (limited to 'gtk/Converter.h')
-rw-r--r--gtk/Converter.h28
1 files changed, 23 insertions, 5 deletions
diff --git a/gtk/Converter.h b/gtk/Converter.h
index c408c220f..09f213a66 100644
--- a/gtk/Converter.h
+++ b/gtk/Converter.h
@@ -4,12 +4,17 @@
// The License.txt file describes the conditions under which this software may be distributed.
#include <iconv.h>
-const iconv_t iconvhBad = (iconv_t)(-1);
+#if GTK_MAJOR_VERSION >= 2
+ typedef GIConv ConverterHandle;
+#else
+ typedef iconv_t ConverterHandle;
+#endif
+const ConverterHandle iconvhBad = (ConverterHandle)(-1);
// Since various versions of iconv can not agree on whether the src argument
// is char ** or const char ** provide a templatised adaptor.
template<typename T>
-size_t iconv_adaptor(size_t(*f_iconv)(iconv_t, T, size_t *, char **, size_t *),
- iconv_t cd, char** src, size_t *srcleft,
+size_t iconv_adaptor(size_t(*f_iconv)(ConverterHandle, T, size_t *, char **, size_t *),
+ ConverterHandle cd, char** src, size_t *srcleft,
char **dst, size_t *dstleft) {
return f_iconv(cd, (T)src, srcleft, dst, dstleft);
}
@@ -17,13 +22,14 @@ size_t iconv_adaptor(size_t(*f_iconv)(iconv_t, T, size_t *, char **, size_t *),
* Encapsulate iconv safely and avoid iconv_adaptor complexity in client code.
*/
class Converter {
- iconv_t iconvh;
+ ConverterHandle iconvh;
public:
Converter() {
iconvh = iconvhBad;
}
Converter(const char *charSetDestination, const char *charSetSource) {
- iconvh = iconv_open(charSetDestination, charSetSource);
+ iconvh = iconvhBad;
+ Open(charSetDestination, charSetSource);
}
~Converter() {
Close();
@@ -34,12 +40,20 @@ public:
void Open(const char *charSetDestination, const char *charSetSource) {
Close();
if (*charSetSource) {
+#if GTK_MAJOR_VERSION >= 2
+ iconvh = g_iconv_open(charSetDestination, charSetSource);
+#else
iconvh = iconv_open(charSetDestination, charSetSource);
+#endif
}
}
void Close() {
if (iconvh != iconvhBad) {
+#if GTK_MAJOR_VERSION >= 2
+ g_iconv_close(iconvh);
+#else
iconv_close(iconvh);
+#endif
iconvh = iconvhBad;
}
}
@@ -47,7 +61,11 @@ public:
if (iconvh == iconvhBad) {
return (size_t)(-1);
} else {
+#if GTK_MAJOR_VERSION >= 2
+ return iconv_adaptor(g_iconv, iconvh, src, srcleft, dst, dstleft);
+#else
return iconv_adaptor(iconv, iconvh, src, srcleft, dst, dstleft);
+#endif
}
}
};