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

Re: Encoding recognizing problem with 2 byte BOM "FF FE"

Expand Messages
  • David Kotchan
    ... I also see this problem for UTF-16LE files using Vim-7.2.025 for (Windows console version). This patch fixes it for me, excellent. Thanks Yanwe. --David
    Message 1 of 5 , Oct 18, 2008
      JiaYanwei wrote:
      > For a 2 byte BOM "FF FE", "ucs-2le" is used, which doesn't work for little-endian UTF-16 text. Like the patch 7.1.261, the only difference is the byte order.
      > And I have also writen a patch for Vim-7.2.025:
      >
      > *** ../vim-7.2.025/src/fileio.c Wed Oct 15 15:09:56 2008
      > --- src/fileio.c Sat Oct 18 11:42:25 2008
      > ***************
      > *** 5550,5559 ****
      > name = "ucs-4le"; /* FF FE 00 00 */
      > len = 4;
      > }
      > ! else if (flags == FIO_ALL || flags == (FIO_UCS2 | FIO_ENDIAN_L))
      > ! name = "ucs-2le"; /* FF FE */
      > ! else if (flags == (FIO_UTF16 | FIO_ENDIAN_L))
      > name = "utf-16le"; /* FF FE */
      > }
      > else if (p[0] == 0xfe && p[1] == 0xff
      > && (flags == FIO_ALL || flags == FIO_UCS2 || flags == FIO_UTF16))
      > --- 5550,5561 ----
      > name = "ucs-4le"; /* FF FE 00 00 */
      > len = 4;
      > }
      > !
      > /* For little endian: default to utf-16, it works also for ucs-2 text. */
      > ! else if (flags == FIO_ALL || flags == (FIO_UTF16 | FIO_ENDIAN_L))
      > name = "utf-16le"; /* FF FE */
      > + else if (flags == (FIO_UCS2 | FIO_ENDIAN_L))
      > + name = "ucs-2le"; /* FF FE */
      > +
      > }
      > else if (p[0] == 0xfe && p[1] == 0xff
      > && (flags == FIO_ALL || flags == FIO_UCS2 || flags == FIO_UTF16))
      > --
      > Best regards,
      > Yanwe
      > >
      I also see this problem for UTF-16LE files using Vim-7.2.025 for
      (Windows console version). This patch fixes it for me, excellent.
      Thanks Yanwe.

      --David

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_dev" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Bram Moolenaar
      ... Looks good, thanks. I ll include it. -- hundred-and-one symptoms of being an internet addict: 164. You got out to buy software, instead of going out for a
      Message 2 of 5 , Nov 1, 2008
        Yanwei wrote:

        > For a 2 byte BOM "FF FE", "ucs-2le" is used, which doesn't work for
        > little-endian UTF-16 text. Like the patch 7.1.261, the only difference
        > is the byte order. And I have also writen a patch for Vim-7.2.025:

        Looks good, thanks. I'll include it.

        --
        hundred-and-one symptoms of being an internet addict:
        164. You got out to buy software, instead of going out for a beer.

        /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
        /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
        \\\ download, build and distribute -- http://www.A-A-P.org ///
        \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

        --~--~---------~--~----~------------~-------~--~----~
        You received this message from the "vim_dev" maillist.
        For more information, visit http://www.vim.org/maillist.php
        -~----------~----~----~----~------~----~------~--~---
      Your message has been successfully submitted and would be delivered to recipients shortly.