#1470 Scite crash with Hebrew charicter set

Bug
closed-fixed
4
2013-08-31
2013-05-02
Ben Sagal
No

after setting character.set=177
if I type in 4 Hebrew characters with code page property encoding scite crashes,
with UTF8 encoding there is no proble

I am using gentoo linux with scite 3.2.5 and 3.3.1.
i have attached Backtrace/Memory map for 3.3.1

1 Attachments

Discussion

  • Neil Hodgson

    Neil Hodgson - 2013-05-02

    Scintilla doesn't really understand right-to-left text such as Hebrew. Even using UTF-8, the caret will move to arbitrary positions in pieces of Hebrew text.

    UTF-8 mode is simpler since its the encoding used by the underlying Pango library. For character.set 177, Scintilla has to map the positions back from UTF-8 to 8859-8 but the character clusters are returned strangely and the code can't cope.

    There doesn't appear to be a reasonable fix short of implementing right-to-left which is unlikely without funding. May be best to just disallow setting character.set to 177.

     
  • Neil Hodgson

    Neil Hodgson - 2013-05-02
    • status: open --> open-accepted
    • Priority: 5 --> 4
     
  • Ben Sagal

    Ben Sagal - 2013-05-03

    I am aware or the lack or rtl support, (and would not even mind the hebrew would even be backwards), but I sometimes find scite useful dealing with source code, witch will occasionally contains a few Hebrew strings,
    I can ignore the problems with dealing and displaying of the stings as most of the workflow dealing with theses files is the rest of the source in ascii.

     
  • Neil Hodgson

    Neil Hodgson - 2013-05-04

    This is ugly but it may work for you:

    diff -r 553989280afb gtk/PlatGTK.cxx
    --- a/gtk/PlatGTK.cxx   Fri Apr 26 11:13:45 2013 +1000
    +++ b/gtk/PlatGTK.cxx   Sat May 04 11:40:29 2013 +1000
    @@ -1059,6 +1059,8 @@
                    if (positionsCalculated < 1 ) {
                        // Either Latin1 or DBCS conversion failed so treat as Latin1.
                        SetConverter(PFont(font_)->characterSet);
    +                   const bool rtlCheck = PFont(font_)->characterSet == SC_CHARSET_HEBREW ||
    +                       PFont(font_)->characterSet == SC_CHARSET_ARABIC;
                        char *utfForm = UTF8FromIconv(conv, s, len);
                        if (!utfForm) {
                            utfForm = UTF8FromLatin1(s, len);
    @@ -1073,6 +1075,17 @@
                            iti.Next();
                            int clusterEnd = iti.curIndex;
                            int ligatureLength = g_utf8_strlen(utfForm + clusterStart, clusterEnd - clusterStart);
    +                       if (rtlCheck && ((clusterEnd <= clusterStart) || (ligatureLength == 0) || (ligatureLength > 3))) {
    +                           // Something has gone wrong: exit quickly but pretend all the characters are equally spaced:
    +                           int widthLayout = 0;
    +                           pango_layout_get_size(layout, &widthLayout, NULL);
    +                           delete []utfForm;
    +                           XYPOSITION widthTotal = doubleFromPangoUnits(widthLayout);
    +                           for (int bytePos=0;bytePos<lenPositions; bytePos++) {
    +                               positions[bytePos] = widthTotal / lenPositions * (bytePos + 1);
    +                           }
    +                           return;                         
    +                       }
                            PLATFORM_ASSERT(ligatureLength > 0 && ligatureLength <= 3);
                            for (int charInLig=0; charInLig<ligatureLength; charInLig++) {
                                positions[i++] = iti.position - (ligatureLength - 1 - charInLig) * iti.distance / ligatureLength;
    
     
  • Neil Hodgson

    Neil Hodgson - 2013-07-22
    • labels: --> scintilla, encoding
    • status: open-accepted --> open-fixed
    • assigned_to: Neil Hodgson
     
  • Neil Hodgson

    Neil Hodgson - 2013-08-31
    • status: open-fixed --> closed-fixed
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks