diff options
author | nyamatongwe <unknown> | 2006-06-24 07:04:42 +0000 |
---|---|---|
committer | nyamatongwe <unknown> | 2006-06-24 07:04:42 +0000 |
commit | 5f62118b5f1f8f957b6d1b2772aef65c9a8784b4 (patch) | |
tree | b879d02171ad3a323f55c107ccd6575908a26306 /gtk/Converter.h | |
parent | 3b5eacd985dd0560ee5c27b8ac2fc38b872c1f07 (diff) | |
download | scintilla-mirror-5f62118b5f1f8f957b6d1b2772aef65c9a8784b4.tar.gz |
If opening a converter in transliterations mode fails, try opening without
transliterations.
Diffstat (limited to 'gtk/Converter.h')
-rw-r--r-- | gtk/Converter.h | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/gtk/Converter.h b/gtk/Converter.h index 7dc2e6875..d3038a2f2 100644 --- a/gtk/Converter.h +++ b/gtk/Converter.h @@ -23,6 +23,16 @@ size_t iconv_adaptor(size_t(*f_iconv)(ConverterHandle, T, size_t *, char **, siz */ class Converter { ConverterHandle iconvh; + void OpenHandle(const char *fullDestination, const char *charSetSource) { +#if GTK_MAJOR_VERSION >= 2 + iconvh = g_iconv_open(fullDestination, charSetSource); +#else + iconvh = iconv_open(fullDestination, charSetSource); +#endif + } + bool Succeeded() const { + return iconvh != iconvhBad; + } public: Converter() { iconvh = iconvhBad; @@ -35,25 +45,26 @@ public: Close(); } operator bool() const { - return iconvh != iconvhBad; + return Succeeded(); } void Open(const char *charSetDestination, const char *charSetSource, bool transliterations=true) { Close(); if (*charSetSource) { - char fullDest[200]; - strcpy(fullDest, charSetDestination); + // Try allowing approximate transliterations if (transliterations) { + char fullDest[200]; + strcpy(fullDest, charSetDestination); strcat(fullDest, "//TRANSLIT"); + OpenHandle(fullDest, charSetSource); + } + if (!Succeeded()) { + // Transliterations failed so try basic name + OpenHandle(charSetDestination, charSetSource); } -#if GTK_MAJOR_VERSION >= 2 - iconvh = g_iconv_open(fullDest, charSetSource); -#else - iconvh = iconv_open(fullDest, charSetSource); -#endif } } void Close() { - if (iconvh != iconvhBad) { + if (Succeeded()) { #if GTK_MAJOR_VERSION >= 2 g_iconv_close(iconvh); #else @@ -63,7 +74,7 @@ public: } } size_t Convert(char** src, size_t *srcleft, char **dst, size_t *dstleft) const { - if (iconvh == iconvhBad) { + if (!Succeeded()) { return (size_t)(-1); } else { #if GTK_MAJOR_VERSION >= 2 |