Loading ...
Sorry, an error occurred while loading the content.

801Re: clipboard for win9x

Expand Messages
  • Glenn Maynard
    Mar 5, 2003
    • 0 Attachment
      Could you please CC: vim-multibyte@... on subjects related to
      Unicode? (I only check vim-dev very rarely, since most of the code I'm
      involved in is multibyte and that list is much lower volume.)

      On Sun, Feb 23, 2003 at 06:23:22PM +0900, MURAOKA Taro wrote:
      > SetClipboardData(CF_UNICODETEXT, hMemW);
      > hMemW = 0;
      > }
      > - else
      > # endif
      > {
      > SetClipboardData(CF_TEXT, hMem);
      > hMem = 0;
      > --- 1231,1238 ----
      > SetClipboardData(CF_UNICODETEXT, hMemW);
      > hMemW = 0;
      > }
      > # endif
      > + if (hMem)
      > {
      > SetClipboardData(CF_TEXT, hMem);
      > hMem = 0;

      This will set *both* Unicode and ANSI text on systems with CF_UNICODETEXT.
      This is bad, because we often set CF_TEXT incorrectly, by putting data in
      it that isn't in the ANSI codepage.

      For example, if encoding=utf-8, and we copy "รบ", UTF-8 will be put
      in CF_TEXT, and we get garbage when we paste. This problem happens even
      on Unicode systems, since many apps don't use the Unicode clipboard directly.

      The attached patch fixes this. After converting the selection to WCHAR,
      we then convert it to the ANSI codepage. This has an added bonus: if
      the conversion was clean, Unicode isn't needed and we can save some
      memory (a lot of memory in some cases).

      It also removes the str_len/metadata.txtlen alias (so they don't
      accidentally get out of sync and cause bugs).

      One thing I'm concerned about is that I havn't yet reproduced the
      reported OE problem, and this may obscure it--it might hide it for the
      person having it, but it probably won't actually fix the problem. I
      havn't been able to reproduce that report; have you (Bram)?

      Glenn Maynard
    • Show all 20 messages in this topic