diff options
| -rw-r--r-- | gtk/PlatGTK.cxx | 34 | ||||
| -rw-r--r-- | gtk/ScintillaGTK.cxx | 43 | 
2 files changed, 52 insertions, 25 deletions
| diff --git a/gtk/PlatGTK.cxx b/gtk/PlatGTK.cxx index b3bb534c3..275e2c40d 100644 --- a/gtk/PlatGTK.cxx +++ b/gtk/PlatGTK.cxx @@ -720,10 +720,10 @@ public:  #ifdef USE_PANGO -static const char *CharacterSetID(int characterSet) { +const char *CharacterSetID(int characterSet) {  	switch (characterSet) {  	case SC_CHARSET_ANSI: -		return "ASCII"; +		return "";  	case SC_CHARSET_DEFAULT:  		return "LATIN1";  	case SC_CHARSET_BALTIC: @@ -1126,11 +1126,11 @@ void SurfaceImpl::DrawTextBase(PRectangle rc, Font &font_, int ybase, const char  					SetIconv(PFont(font_)->characterSet);  					utfForm = UTF8FromIconv(iconvh, s, len);  				} -				if (!utfForm) {	// DBCS failed so treat as locale -					gsize w; // stub -					utfForm = g_locale_to_utf8(s, len, NULL, &w, NULL); -					useGFree = static_cast<bool>(utfForm); -				}; +				//~ if (!utfForm) {	// DBCS failed so treat as locale +					//~ gsize w; // stub +					//~ utfForm = g_locale_to_utf8(s, len, NULL, &w, NULL); +					//~ useGFree = static_cast<bool>(utfForm); +				//~ };  				if (!utfForm) {	// g_locale_to_utf8 failed so treat as Latin1  					utfForm = UTF8FromLatin1(s, len);  				} @@ -1269,11 +1269,11 @@ void SurfaceImpl::MeasureWidths(Font &font_, const char *s, int len, int *positi  					bool useGFree = false;  					SetIconv(PFont(font_)->characterSet);  					char *utfForm = UTF8FromIconv(iconvh, s, len); -					if (!utfForm) {	// iconv failed so treat as locale -						gsize w; // stub -						utfForm = g_locale_to_utf8(s, len, NULL, &w, NULL); -						useGFree = static_cast<bool>(utfForm); -					} +					//~ if (!utfForm) {	// iconv failed so treat as locale +						//~ gsize w; // stub +						//~ utfForm = g_locale_to_utf8(s, len, NULL, &w, NULL); +						//~ useGFree = static_cast<bool>(utfForm); +					//~ }  					if (!utfForm) {  						utfForm = UTF8FromLatin1(s, len);  					} @@ -1368,11 +1368,11 @@ int SurfaceImpl::WidthText(Font &font_, const char *s, int len) {  					SetIconv(PFont(font_)->characterSet);  					utfForm = UTF8FromIconv(iconvh, s, len);  				} -				if (!utfForm) {	// iconv failed so treat as locale -					gsize w; -					utfForm = g_locale_to_utf8(s, len, NULL, &w, NULL); -					useGFree = static_cast<bool>(utfForm); -				}; +				//~ if (!utfForm) {	// iconv failed so treat as locale +					//~ gsize w; +					//~ utfForm = g_locale_to_utf8(s, len, NULL, &w, NULL); +					//~ useGFree = static_cast<bool>(utfForm); +				//~ };  				if (!utfForm) {	// g_locale_to_utf8 failed so treat as Latin1  					utfForm = UTF8FromLatin1(s, len);  				} diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx index d3753b5d2..4e7b62bb9 100644 --- a/gtk/ScintillaGTK.cxx +++ b/gtk/ScintillaGTK.cxx @@ -54,6 +54,8 @@  #if GTK_MAJOR_VERSION < 2  #define INTERNATIONAL_INPUT +#else +#include <iconv.h>  #endif  #ifdef _MSC_VER @@ -846,18 +848,43 @@ void ScintillaGTK::NotifyURIDropped(const char *list) {  	NotifyParent(scn);  } +const char *CharacterSetID(int characterSet);  int ScintillaGTK::KeyDefault(int key, int modifiers) {  	if (!(modifiers & SCI_CTRL) && !(modifiers & SCI_ALT)) {  #if GTK_MAJOR_VERSION >= 2 -		if (IsUnicodeMode() && (key <= 0xFE00)) { -			char utfval[4]="\0\0\0"; -			wchar_t wcs[2]; -			wcs[0] = gdk_keyval_to_unicode(key); -			wcs[1] = 0; -			UTF8FromUCS2(wcs, 1, utfval, 3); -			AddCharUTF(utfval,strlen(utfval)); -			return 1; +		char utfVal[4]="\0\0\0"; +		wchar_t wcs[2]; +		wcs[0] = gdk_keyval_to_unicode(key); +		wcs[1] = 0; +		UTF8FromUCS2(wcs, 1, utfVal, 3); +		if (key <= 0xFE00) { +			if (IsUnicodeMode()) { +				AddCharUTF(utfVal,strlen(utfVal)); +				return 1; +			} else { +				const char *source = +					CharacterSetID(vs.styles[STYLE_DEFAULT].characterSet); +				if (*source) { +					iconv_t iconvh = iconv_open("UTF8", source); +					if (iconvh != ((iconv_t)(-1))) { +						char localeVal[4]="\0\0\0"; +						char *pin = utfVal; +						size_t inLeft = strlen(utfVal); +						char *pout = localeVal; +						size_t outLeft = sizeof(localeVal); +						size_t conversions = iconv(iconvh, &pin, &inLeft, &pout, &outLeft); +						iconv_close(iconvh); +						if (conversions != ((size_t)(-1))) { +							*pout = '\0'; +							for (int i=0; localeVal[i]; i++) { +								AddChar(localeVal[i]); +							} +							return 1; +						} +					} +				} +			}  		}  #endif  		if (key < 256) { | 
