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

Re: use vim to "translate" Chinese (simplified/traditional)

Expand Messages
  • Antoine J. Mechelynck
    ... see :help stridx() ... should be the same in reverse (i.e. reversing the roles of the two arrays) [...] Seems interesting. I suppose it can be assumed
    Message 1 of 2 , May 29, 2004
    • 0 Attachment
      Xiangjiang Ma <maxiangjiang@...> wrote:
      > Hi,
      >
      > I am interested in "translating" between the simplified Chinese
      > and the traditional Chinese using vim functions/scripts. This is
      > more like what "gu" and "gU" do for ASCII. Anyone out there can
      > help with the following task 3?
      >
      > I will add it to http://vim.sourceforge.net/tips
      > if it can be done successfully.
      >
      >
      > Assumptions:
      >
      > 1. There is one-to-one map between the Simplified Chinese and the
      > Traditional Chinese (80% true in real life?)
      > 2. The encoding is set to be utf-8
      >
      >
      > Tasks:
      >
      > 1. define a Simplified_Chinese_String, with 6000 unicode point (DONE)
      > 2. define a Traditional_Chinese_String, with 6000 unicode point (DONE)
      > 3. write one function to do transform from Simplified to Traditional
      > a) loop through the whole vim buffer
      > b) for every char, find its index in the Simplified_Chinese_String

      see ":help stridx()"

      > c) use the index to replace the char with the corresponding
      > Traditional which can be found from the
      > Traditional_Chinese_String
      > 4. write one function to do transform from Traditional to Simplified

      should be the same in reverse (i.e. reversing the roles of the two arrays)
      [...]

      Seems interesting. I suppose it can be assumed that anything "not found in
      table" is to be kept without change. To speedup the conversion, "codepoint
      ranges" might be defined, so that out-of-range values would be left
      unchanged with no lookup.

      I look forward to seeing this in vim script.
      Tony.
    Your message has been successfully submitted and would be delivered to recipients shortly.