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

Re: utf-8 based char2nr/nr2char.

Expand Messages
  • Tony Mechelynck
    ... char2nr() and nr2char() use your current encoding , which may be other than the locale you had at startup and even than your current :language ctype . I
    Message 1 of 7 , Dec 26, 2012
    • 0 Attachment
      On 26/12/12 09:00, mattn wrote:
      > Hi, bram and all.
      >
      > In some times, I want to use utf-8 character based char2nr/nr2char.
      > Currently, char2nr/nr2char works depend on locale characters. But I guess someone hope to use utf-8 character based char2nr/nr2char.
      > I added second argument which treat first argument as utf-8.
      >
      > https://gist.github.com/1686178
      >

      char2nr() and nr2char() use your current 'encoding', which may be other
      than the locale you had at startup and even than your current ":language
      ctype".

      I recommend to set your 'encoding' to utf-8 near the top of your vimrc
      (if the current Vim is compiled with +multi_byte). See how at
      http://vim.wikia.com/wiki/Working_with_Unicode

      Note that if you change 'encoding' after some file has been loaded for
      editing, you run the risk of corrupting that file's text (unless it
      happens to consist entirely of 7-bit US-ASCII characters).


      Best regards,
      Tony.
      --
      Sweater, n.:
      A garment worn by a child when its mother feels chilly.

      --
      You received this message from the "vim_dev" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php
    • mattn
      ... No, changing encoding occur refreshing. So It can t use char2nr gracefully. -- You received this message from the vim_dev maillist. Do not top-post! Type
      Message 2 of 7 , Dec 26, 2012
      • 0 Attachment
        > I recommend to set your 'encoding' to utf-8 near the top of your vimrc
        >
        > (if the current Vim is compiled with +multi_byte). See how at
        >
        > http://vim.wikia.com/wiki/Working_with_Unicode
        >
        >
        >
        > Note that if you change 'encoding' after some file has been loaded for
        >
        > editing, you run the risk of corrupting that file's text (unless it
        >
        > happens to consist entirely of 7-bit US-ASCII characters).

        No, changing encoding occur refreshing. So It can't use char2nr gracefully.

        --
        You received this message from the "vim_dev" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php
      • mattn
        ... The changing &encoding option affect to substitute(), strXXX or many another functions. The new feature I want is, getting character from utf-8 codepoint,
        Message 3 of 7 , Dec 26, 2012
        • 0 Attachment
          > No, changing encoding occur refreshing. So It can't use char2nr gracefully.

          The changing &encoding option affect to substitute(), strXXX or many another functions. The new feature I want is, getting character from utf-8 codepoint, Just it.


          --
          You received this message from the "vim_dev" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php
        • Tony Mechelynck
          ... Well, if you set your encoding to utf-8 once and for all in your vimrc (before any file is loaded), char2nr() will give you the Unicode codepoint number
          Message 4 of 7 , Dec 26, 2012
          • 0 Attachment
            On 26/12/12 10:03, mattn wrote:
            >> No, changing encoding occur refreshing. So It can't use char2nr gracefully.
            >
            > The changing &encoding option affect to substitute(), strXXX or many another functions. The new feature I want is, getting character from utf-8 codepoint, Just it.
            >
            >
            Well, if you set your 'encoding' to utf-8 once and for all in your vimrc
            (before any file is loaded), char2nr() will give you the Unicode
            codepoint number of the first character in its String argument.
            Similarly, nr2char() will give you (as a single character of one or more
            bytes) the Unicode codepoint corresponding to its integer argument.

            I don't understand your sentence "it can't use char2nr gracefully". If
            'encoding' is set to utf-8, you'll need some fancy footwork to get the
            character's value from the 'fileencoding' point-of-view if different,
            but it's possible via iconv().


            Best regards,
            Tony.
            --
            Indifference will be the downfall of mankind, but who cares?

            --
            You received this message from the "vim_dev" maillist.
            Do not top-post! Type your reply below the text you are replying to.
            For more information, visit http://www.vim.org/maillist.php
          • Bram Moolenaar
            ... Thanks, I ll add it to the todo list. -- hundred-and-one symptoms of being an internet addict: 211. Your husband leaves you...taking the computer with him
            Message 5 of 7 , Dec 29, 2012
            • 0 Attachment
              Yasuhiro Matsumoto wrote:

              > In some times, I want to use utf-8 character based char2nr/nr2char.
              > Currently, char2nr/nr2char works depend on locale characters. But I guess someone hope to use utf-8 character based char2nr/nr2char.
              > I added second argument which treat first argument as utf-8.
              >
              > https://gist.github.com/1686178

              Thanks, I'll add it to the todo list.

              --
              hundred-and-one symptoms of being an internet addict:
              211. Your husband leaves you...taking the computer with him and you
              call him crying, and beg him to bring the computer back.

              /// Bram Moolenaar -- Bram@... -- http://www.Moolenaar.net \\\
              /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
              \\\ an exciting new programming language -- http://www.Zimbu.org ///
              \\\ help me help AIDS victims -- http://ICCF-Holland.org ///

              --
              You received this message from the "vim_dev" maillist.
              Do not top-post! Type your reply below the text you are replying to.
              For more information, visit http://www.vim.org/maillist.php
            Your message has been successfully submitted and would be delivered to recipients shortly.