aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xgtk/ScintillaGTK.cxx19
1 files changed, 2 insertions, 17 deletions
diff --git a/gtk/ScintillaGTK.cxx b/gtk/ScintillaGTK.cxx
index 9c9e36c1a..2985aab54 100755
--- a/gtk/ScintillaGTK.cxx
+++ b/gtk/ScintillaGTK.cxx
@@ -2601,23 +2601,8 @@ bool ScintillaGTK::RetrieveSurroundingThis(GtkIMContext *context) {
const Sci::Position startByte = pdoc->LineStart(line);
const Sci::Position endByte = pdoc->LineEnd(line);
- std::string utf8Text;
- gint cursorIndex; // index of the cursor inside utf8Text, in bytes
- const char *charSetBuffer;
-
- if (IsUnicodeMode() || ! *(charSetBuffer = CharacterSetID())) {
- utf8Text = RangeText(startByte, endByte);
- cursorIndex = pos - startByte;
- } else {
- // Need to convert
- std::string tmpbuf = RangeText(startByte, pos);
- utf8Text = ConvertText(&tmpbuf[0], tmpbuf.length(), "UTF-8", charSetBuffer, false);
- cursorIndex = utf8Text.length();
- if (endByte > pos) {
- tmpbuf = RangeText(pos, endByte);
- utf8Text += ConvertText(&tmpbuf[0], tmpbuf.length(), "UTF-8", charSetBuffer, false);
- }
- }
+ std::string utf8Text = UTF8FromEncoded(RangeText(startByte, endByte));
+ gint cursorIndex = UTF8FromEncoded(RangeText(startByte, pos)).length();
gtk_im_context_set_surrounding(context, &utf8Text[0], utf8Text.length(), cursorIndex);