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

Re: Null character handling

Expand Messages
  • Bram Moolenaar
    ... The problem is that NL (ascii 10) is a newline in a Vim script string and a NUL in a line of the file. Thus it depends what you use it for. This can t be
    Message 1 of 3 , Aug 11, 2003
      Ben Siemerink wrote:

      > There are two peculiarities I want to bring up:
      >
      > [1] nr2char(0) does not yield the internal representative of the null
      > character. Rather, nr2char(10) must be used. To me this is a bug.

      The problem is that NL (ascii 10) is a newline in a Vim script string
      and a NUL in a line of the file. Thus it depends what you use it for.
      This can't be changed now without causing lots of incompatibilities.

      I'll add a remark about this at the docs for nr2char().

      > [2] When sourcing a Vim file, ^@ is not interpreted as the internal
      > representative of the null character, but rather as an end-of-string. To me
      > this is also a bug.

      Again, this depends on where you use it and can't be changed without
      becoming incompatible with previous versions.

      > Does everybody agree that, from a user point of view, these are bugs?
      > A user should not need to know that the null character is internally
      > stored as a 0x0a, not even an advanced user.

      Unfortunately you do have to know about this when writing Vim scripts.
      Also in search strings, for example.

      --
      From "know your smileys":
      % Bike accident (a bit far-fetched, I suppose)

      /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
      /// Creator of Vim - Vi IMproved -- http://www.Vim.org \\\
      \\\ Project leader for A-A-P -- http://www.A-A-P.org ///
      \\\ Help AIDS victims, buy here: http://ICCF-Holland.org/click1.html ///
    Your message has been successfully submitted and would be delivered to recipients shortly.