Hi Bram,

On 9/11/07, Bram Moolenaar <[EMAIL PROTECTED]> wrote:
> [...]
>
> Only two bytes are put in buf[], thus more needs to be changed here to
> make it work.
>
> [...]
>
> Here too.
> [...]

I don't know how to deal with the characters outside BMP for XChar2b.
I just assume that it is UTF-16. Please help me check this patch:

Index: gui_x11.c
===================================================================
--- gui_x11.c   (revision 513)
+++ gui_x11.c   (working copy)
@@ -2562,17 +2562,39 @@
 # ifdef FEAT_XFONTSET
            if (current_fontset != NULL)
            {
-               if (c >= 0x10000 && sizeof(wchar_t) <= 2)
+#ifdef UNICODE16
+               if (c >= 0x10000)
                    c = 0xbf;           /* show chars > 0xffff as ? */
+#endif
                ((wchar_t *)buf)[wlen] = c;
            }
            else
 # endif
            {
+#ifdef UNICODE16
                if (c >= 0x10000)
                    c = 0xbf;           /* show chars > 0xffff as ? */
                ((XChar2b *)buf)[wlen].byte1 = (unsigned)c >> 8;
                ((XChar2b *)buf)[wlen].byte2 = c;
+#else
+               if (c < 0x10000)
+                {
+                    ((XChar2b *)buf)[wlen].byte1 = (unsigned)c >> 8;
+                    ((XChar2b *)buf)[wlen].byte2 = c;
+                }
+                else
+                {
+                    unsigned short first, second;
+                    c -= 0x10000;
+                    first = c >> 10 + 0xD800;
+                    second = c & 0x3FFUL + 0xDC00;
+                    ((XChar2b *)buf)[wlen].byte1 = first >> 8;
+                    ((XChar2b *)buf)[wlen].byte2 = first;
+                    ++wlen;
+                    ((XChar2b *)buf)[wlen].byte1 = second >> 8;
+                    ((XChar2b *)buf)[wlen].byte2 = second;
+                }
+#endif
            }
            ++wlen;
            cells += utf_char2cells(c);
Index: gui_gtk_x11.c
===================================================================
--- gui_gtk_x11.c       (revision 513)
+++ gui_gtk_x11.c       (working copy)
@@ -6057,7 +6057,8 @@
        if (buflen < len)
        {
            XtFree((char *)buf);
-           buf = (XChar2b *)XtMalloc(len * sizeof(XChar2b));
+           buf = (XChar2b *)XtMalloc(len * (sizeof(XChar2b) < sizeof(wchar_t)
+                                       ? sizeof(wchar_t) : sizeof(XChar2b)));
            buflen = len;
        }

@@ -6070,10 +6071,30 @@
            if (enc_utf8)
            {
                c = utf_ptr2char(p);
+#ifdef UNICODE16
                if (c >= 0x10000)       /* show chars > 0xffff as ? */
                    c = 0xbf;
                buf[textlen].byte1 = c >> 8;
                buf[textlen].byte2 = c;
+#else
+               if (c < 0x10000)
+                {
+                    buf[textlen].byte1 = c >> 8;
+                    buf[textlen].byte2 = c;
+                }
+                else
+                {
+                    unsigned short first, second;
+                    c -= 0x10000;
+                    first = c >> 10 + 0xD800;
+                    second = c & 0x3FFUL + 0xDC00;
+                    buf[textlen].byte1 = first >> 8;
+                    buf[textlen].byte2 = first;
+                    ++textlen;
+                    buf[textlen].byte1 = second >> 8;
+                    buf[textlen].byte2 = second;
+                }
+#endif
                p += utf_ptr2len(p);
                width += utf_char2cells(c);
            }


Regards,


Edward L. Fox

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui