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

Can we have one hard-coded unicode string for all encodings?

Expand Messages
  • Sean
    Hello, It can be done if I have a separate file, but I want to do it all in one plugin. I could not make it work by playing with iconv() function. My current
    Message 1 of 2 , Jan 25, 2009
    • 0 Attachment
      Hello,

      It can be done if I have a separate file, but I want to do it all in
      one plugin. I could not make it work by playing with iconv()
      function.

      My current workaround works, by manually getting unicode value from
      different encoding.

      if &encoding == "utf-8"
      let utf8_value = [ "<C-V>uff08", "<C-V>uff09",
      \ "<C-V>u300e", "<C-V>u300f", "<C-V>u3010", "<C-V>u3011",
      \ "<C-V>u300a", "<C-V>u300b", "<C-V>uff0b", "<C-V>uff0d"]
      elseif &encoding == "cp936"
      let cp936_value = ["<C-V>ua3a8", "<C-V>ua3a9",
      \ "<C-V>ua1ba", "<C-V>ua1bb", "<C-V>ua1be", "<C-V>ua1bf",
      \ "<C-V>ua1b6", "<C-V>ua1b7", "<C-V>ua3ab", "<C-V>ua3ad"]
      endif

      I am wondering if there is a better way by doing it automatically,
      using only one utf-8 string.

      Thanks

      Sean

      --~--~---------~--~----~------------~-------~--~----~
      You received this message from the "vim_use" maillist.
      For more information, visit http://www.vim.org/maillist.php
      -~----------~----~----~----~------~----~------~--~---
    • Sean
      ... I found the answer by myself. All I need is to add one line in my plugin: scriptencoding utf-8 Then, I don t need to do my manual translation and I can
      Message 2 of 2 , Jan 31, 2009
      • 0 Attachment
        On Jan 25, 11:13 pm, Sean <maxiangji...@...> wrote:
        > Hello,
        >
        > It can be done if I have a separate file, but I want to do it all in
        > one plugin.  I could not make it work by playing with iconv()
        > function.
        >
        > My current workaround works, by manually getting unicode value from
        > different encoding.
        >
        > if &encoding == "utf-8"
        >     let utf8_value = [ "<C-V>uff08", "<C-V>uff09",
        >     \ "<C-V>u300e", "<C-V>u300f", "<C-V>u3010", "<C-V>u3011",
        >     \ "<C-V>u300a", "<C-V>u300b", "<C-V>uff0b", "<C-V>uff0d"]
        > elseif &encoding == "cp936"
        >     let cp936_value =  ["<C-V>ua3a8", "<C-V>ua3a9",
        >     \ "<C-V>ua1ba", "<C-V>ua1bb", "<C-V>ua1be", "<C-V>ua1bf",
        >     \ "<C-V>ua1b6", "<C-V>ua1b7", "<C-V>ua3ab", "<C-V>ua3ad"]
        > endif
        >
        > I am wondering if there is a better way by doing it automatically,
        > using only one utf-8 string.

        I found the answer by myself.

        All I need is to add one line in my plugin:

        scriptencoding utf-8

        Then, I don't need to do my manual translation and I can also add real
        words inside my plugin, not something like <C-V>uXXXX.

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